[#111472] [Ruby master Bug#19274] Error installing ruby 3.2.0 on RH 8 — "aalllop (Alberto Allegue) via ruby-core" <ruby-core@...>
Issue #19274 has been reported by aalllop (Alberto Allegue).
5 messages
2022/12/28
[#111508] Data support for versions before 3.2.0 — Eustáquio Rangel via ruby-core <ruby-core@...>
I was wondering that every piece of code (gems, etc) that use the new Data =
3 messages
2022/12/29
[ruby-core:111425] [Ruby master Feature#19236] Allow to create hashes with a specific capacity from Ruby
From:
janosch-x via ruby-core <ruby-core@...>
Date:
2022-12-25 17:16:47 UTC
List:
ruby-core #111425
Issue #19236 has been updated by janosch-x (Janosch M=FCller).
maybe the genie is out of the bottle already, but it would be nice to have =
a uniform API for creating objects with a given capacity, e.g.
```ruby
Array.with_capacity(100) # =3D> []
Hash.with_capacity(100) # =3D> {}
IO::Buffer.with_capacity(100) # =3D> #<IO::Buffer>
String.with_capacity(100) # =3D> ''
# more?
```
for `Array` and `IO::Buffer`, `::with_capacity` would essentially be an ali=
as for `::new`. for `String`, the `capacity` kwarg could be deprecated to l=
imit the number of APIs.
----------------------------------------
Feature #19236: Allow to create hashes with a specific capacity from Ruby
https://bugs.ruby-lang.org/issues/19236#change-100797
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
* Target version: 3.3
----------------------------------------
Followup on [Feature #18683] which added a C-API for this purpose.
Various protocol parsers such as Redis `RESP3` or `msgpack`, have to create=
hashes, and they know the size in advance.
For efficiency, it would be preferable if they could directly allocate a Ha=
sh of the necessary size, so that large hashes wouldn't cause many re-alloc=
cations and re-hash.
`String` and `Array` both already offer similar APIs:
```ruby
String.new(capacity: XXX)
Array.new(XX) / rb_ary_new_capa(long)
```
However there's no such public API for Hashes in Ruby land.
### Proposal
I think `Hash` should have a way to create a new hash with a `capacity` par=
ameter.
The logical signature of `Hash.new(capacity: 1000)` was deemed too incompat=
ible in [Feature #18683].
@Eregon proposed to add `Hash.create(capacity: 1000)`.
--=20
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-c=
ore.ml.ruby-lang.org/