From: mohsen@... Date: 2019-05-31T19:31:24+00:00 Subject: [ruby-core:92916] [Ruby trunk Bug#15807] Range#minmax is slow and never returns for endless ranges Issue #15807 has been updated by mohsen (Mohsen Alizadeh). i had the same problem with minmax in Range. I made a MR https://github.com/ruby/ruby/pull/2216 ---------------------------------------- Bug #15807: Range#minmax is slow and never returns for endless ranges https://bugs.ruby-lang.org/issues/15807#change-78292 * Author: janosch-x (Janosch M�ller) * 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: