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=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 1D10B1F8C6 for ; Fri, 9 Jul 2021 06:30:47 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 4AB31120A51; Fri, 9 Jul 2021 15:29:31 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 31F56120A42 for ; Fri, 9 Jul 2021 15:29:29 +0900 (JST) Received: by filterdrecv-776cdd9c85-mnwcz with SMTP id filterdrecv-776cdd9c85-mnwcz-1-60E7ED10-113 2021-07-09 06:30:40.745126523 +0000 UTC m=+128383.932776900 Received: from herokuapp.com (unknown) by ismtpd0181p1mdw1.sendgrid.net (SG) with ESMTP id 6mYfz4ooQ5qa_InBKFeJyA for ; Fri, 09 Jul 2021 06:30:40.550 +0000 (UTC) Date: Fri, 09 Jul 2021 06:30:40 +0000 (UTC) From: samuel@oriontransfer.net Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 18033 X-Redmine-Issue-Author: nobu X-Redmine-Sender: ioquatix 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-Redmine-MailingListIntegration-Message-Ids: 80680 X-SG-EID: =?us-ascii?Q?cjxb6GWHefMLoR50bkJBcGo6DRiDl=2FNYcMZdY+Wj30TF2snvx4LidLIR=2FekN7T?= =?us-ascii?Q?o3dHTOE67fz44DQs58ejt=2FIeK7le+pJ7A9bOAHe?= =?us-ascii?Q?ziN7dCLRnos4eHF8QJ6reizhR65lVZIUSBvToBA?= =?us-ascii?Q?Rfb3HDddu9y2yUYIGp4er5F9a6RAdRttDH5XaXO?= =?us-ascii?Q?P5FXn3dwpp5dPaqqjuNY97=2F9Ykna+4g7UswNIeS?= =?us-ascii?Q?VRztwF2eoQl08iUGY=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 104554 Subject: [ruby-core:104554] [Ruby master Feature#18033] Time.new to parse a string 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="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #18033 has been updated by ioquatix (Samuel Williams). It looks like good improvement. But does any other `#new` implementation work this way? Can we fix `Time#parse`? I wonder if user will be confused, should they use `Time.parse` or `Time.new`? Why is `Time.parse` so slow? This seems like a good performance improvement. But rather than fixing the existing `#parse`, we introduce new one. Now we move the complexity to the user. ---------------------------------------- Feature #18033: Time.new to parse a string https://bugs.ruby-lang.org/issues/18033#change-92833 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Priority: Normal ---------------------------------------- Make `Time.new` parse `Time#inspect` and ISO-8601 like strings. * `Time.iso8601` and `Time.parse` need an extension library, `date`. * `Time.iso8601` can't parse `Time#inspect` string. * `Time.parse` often results in unintentional/surprising results. * `Time.new` also about 1.9 times faster than `Time.iso8601`. ``` $ ./ruby -rtime -rbenchmark -e ' n = 1000 s = Time.now.iso8601 Benchmark.bm(12) do |x| x.report("Time.iso8601") {n.times{Time.iso8601(s)}} x.report("Time.parse") {n.times{Time.parse(s)}} x.report("Time.new") {n.times{Time.new(s)}} end' user system total real Time.iso8601 0.006919 0.000185 0.007104 ( 0.007091) Time.parse 0.018338 0.000207 0.018545 ( 0.018590) Time.new 0.003671 0.000069 0.003740 ( 0.003741) ``` https://github.com/ruby/ruby/pull/4639 -- https://bugs.ruby-lang.org/