From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.6 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id D265B1F462 for ; Sat, 15 Jun 2019 09:50:32 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E36B4120A37; Sat, 15 Jun 2019 18:50:25 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 10A7C120A37 for ; Sat, 15 Jun 2019 18:50:23 +0900 (JST) Received: by filter0191p3mdw1.sendgrid.net with SMTP id filter0191p3mdw1-26613-5D04BF61-C 2019-06-15 09:50:25.201849384 +0000 UTC m=+149941.896022354 Received: from herokuapp.com (unknown [3.82.96.57]) by ismtpd0037p1mdw1.sendgrid.net (SG) with ESMTP id wXXx-_ojRSuUmJANPbfmzQ for ; Sat, 15 Jun 2019 09:50:25.106 +0000 (UTC) Date: Sat, 15 Jun 2019 09:50:25 +0000 (UTC) From: janosch84@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68642 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15807 X-Redmine-Issue-Author: janosch-x X-Redmine-Sender: janosch-x X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?0k5sXJRcmdpWYfOD1oWBjpTENp+mR02klozhrfvpSZJ7pfZ++tUsNGG7fAsJqw?= =?us-ascii?Q?ib+skbSDeovokYGxp7xBGJUs3J9l+N50xItTsSO?= =?us-ascii?Q?bOTVxJxxFnL+CFkBcBHWn7mACWOIcNkhKZP+J84?= =?us-ascii?Q?VoUuFMKLHXH=2FdTR0LV7TIVdvhO8d+q6KVG1Bodt?= =?us-ascii?Q?ywwU0sUDvdSfTkQ3mnmi+oYHHW7zzI9BTtA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93156 Subject: [ruby-core:93156] [Ruby trunk Bug#15807] Range#minmax is slow and never returns for endless ranges X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15807 has been updated by janosch-x (Janosch M=FCller). jeremyevans0 (Jeremy Evans) wrote: > I think this is a bug we should fix, even if it breaks code relying on th= is bug ("all bug fixes are incompatibilities" :)). Yes, it is a bit reminiscent of https://xkcd.com/1172/ :) > Does anyone have an opinion on whether `minmax` should call overridden `m= in` and `max` methods? Or do we expect if you override `min` or `max`, you= should also override `minmax`? I don't have a strong opinion either way. Other classes including Enumerable also require `minmax` to be overridden i= ndividually. `Set` or `SortedSet` are examples from the stdlib. So I guess = it would be more consistent to call the C functions. ---------------------------------------- Bug #15807: Range#minmax is slow and never returns for endless ranges https://bugs.ruby-lang.org/issues/15807#change-78599 * Author: janosch-x (Janosch M=FCller) * 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! ---Files-------------------------------- range-minmax.patch (2.89 KB) -- = https://bugs.ruby-lang.org/ Unsubscribe: