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=-3.9 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham 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 772C51F453 for ; Sun, 28 Apr 2019 12:33:13 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 195291209E8; Sun, 28 Apr 2019 21:33:07 +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 7B93F1208D1 for ; Sun, 28 Apr 2019 21:33:04 +0900 (JST) Received: by filter0078p3mdw1.sendgrid.net with SMTP id filter0078p3mdw1-11482-5CC59D61-24 2019-04-28 12:32:33.586602211 +0000 UTC m=+229628.524953513 Received: from herokuapp.com (unknown [54.91.45.152]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id _e9huk_0QyC_trOK1jo3Kw for ; Sun, 28 Apr 2019 12:32:33.482 +0000 (UTC) Date: Sun, 28 Apr 2019 12:32:33 +0000 (UTC) From: mame@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67944 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15807 X-Redmine-Issue-Author: janosch-x X-Redmine-Sender: mame 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?EJh2gqwnyqXtd++xo=2FinyA1V0bXouTB4FkWnzNiKb4=2F7mYXZ1BkcynJFATCulY?= =?us-ascii?Q?wszQk5=2FVhtRynPr54pA7yTB6mSR59wPBvKXC6f1?= =?us-ascii?Q?7Pzqoq69siT9juMGOLpd+j9kUJobq2o+i+CZYZx?= =?us-ascii?Q?gwFYfTlfHRmOR7aBvVmJrUNt3RhksRnNtwLAjnW?= =?us-ascii?Q?ghEIIrfp9ztO2Q635LiLk9gHyCN5L4h4sWQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92461 Subject: [ruby-core:92461] [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 mame (Yusuke Endoh). I'm never against fixing this issue but I have one concern. Currently, `Ra= nge#max` is not consistent with `Enumerable#minmax`. ``` p ("a".."aa").max #=3D> "aa" p ("a".."aa").minmax #=3D> ["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 incompatibili= ty. Do you have any use case? Or, are you facing any concrete issue that is ca= used by this inconsistency? If so, we can believe that it would be worth f= ixing 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 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! -- = https://bugs.ruby-lang.org/ Unsubscribe: