[#92070] [Ruby trunk Feature#15667] Introduce malloc_trim(0) in full gc cycles — sam.saffron@...
Issue #15667 has been updated by sam.saffron (Sam Saffron).
3 messages
2019/04/01
[ruby-core:92461] [Ruby trunk Bug#15807] Range#minmax is slow and never returns for endless ranges
From:
mame@...
Date:
2019-04-28 12:32:33 UTC
List:
ruby-core #92461
Issue #15807 has been updated by mame (Yusuke Endoh).
I'm never against fixing this issue but I have one concern. Currently, `Range#max` is not consistent with `Enumerable#minmax`.
```
p ("a".."aa").max #=> "aa"
p ("a".."aa").minmax #=> ["a", "z"]
```
Thus, if `Range#minmax` is simply implemented, it will make it consistent. This is not always good because it means that the fix brings incompatibility.
Do you have any use case? Or, are you facing any concrete issue that is caused by this inconsistency? If so, we can believe that it would be worth fixing this issue. If not, we need to consider.
----------------------------------------
Bug #15807: Range#minmax is slow and never returns for endless ranges
https://bugs.ruby-lang.org/issues/15807#change-77810
* Author: janosch-x (Janosch Mler)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.6.3p62
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
current situation:
- `(1..).minmax` runs forever
- `(1..).max` raises "cannot get the maximum of endless range"
- `(1..Float::INFINITY).minmax` runs forever
- `(1..Float::INFINITY).max` returns instantly
- `(1..1_000_000_000).minmax` takes one minute
- `(1..1_000_000_000).max` returns instantly
my suggestion:
- implement `minmax` in range.c, return [`range_min`, `range_max`]
- for endless ranges, this will trigger the same error as `max` does
- delegate to enum (rb_call_super) only if called with a block (?)
i could perhaps provide a PR if you can point me to some information on how to contribute.
cheers!
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>