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=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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 CB6511F609 for ; Thu, 13 Jun 2019 06:05:16 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id D9360120AF2; Thu, 13 Jun 2019 15:05:10 +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 C0A3F120AFD for ; Thu, 13 Jun 2019 15:05:08 +0900 (JST) Received: by filter0058p3iad2.sendgrid.net with SMTP id filter0058p3iad2-20267-5D01E796-36 2019-06-13 06:05:10.6956342 +0000 UTC m=+738747.190975454 Received: from herokuapp.com (unknown [52.207.231.138]) by ismtpd0039p1iad2.sendgrid.net (SG) with ESMTP id WYRIkDijQI2-W_cWk8iEBg for ; Thu, 13 Jun 2019 06:05:10.648 +0000 (UTC) Date: Thu, 13 Jun 2019 06:05:10 +0000 (UTC) From: duerst@it.aoyama.ac.jp Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68576 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15836 X-Redmine-Issue-Author: byroot X-Redmine-Sender: duerst 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?uQY=2F2xNrNfHHTWbKn6MBvvzfU5Pqk9I4lnOVb0CFDuu6W+WAeEY9jg4yRSezRl?= =?us-ascii?Q?aJu0Bun0IU4J0QAKZ+6L2NLEuGRuTw20IdhfyDW?= =?us-ascii?Q?9=2F3JUyGzOGCFDFlbTHakyIIIG=2FS3poGqT4NpVZa?= =?us-ascii?Q?BxqlZ3Pc2GWzDXrxmYxB9pIlbmPZTGYPwUQg=2FU7?= =?us-ascii?Q?pqCnqj+4d8=2F+Mof0NbjolO8z2JLYMTJhZFQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93090 Subject: [ruby-core:93090] [Ruby trunk Feature#15836] [Proposal] Make Module#name and Symbol#to_s return their internal fstrings 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 #15836 has been updated by duerst (Martin D=FCrst). Isn't one main purpose of converting a Symbol to a String that you want to = change the symbol string? This proposal would make that use case more tedio= us. ---------------------------------------- Feature #15836: [Proposal] Make Module#name and Symbol#to_s return their in= ternal fstrings https://bugs.ruby-lang.org/issues/15836#change-78512 * Author: byroot (Jean Boussier) * Status: Feedback * Priority: Normal * Assignee: = * Target version: = ---------------------------------------- # Why ? In many codebases, especially Rails apps, these two methods are the source = of quite a lot of object allocations. `Module#name` is often accessed for various introspection features, autoloa= ding etc. `Symbol#to_s` is access a lot by HashWithIndifferentAccess other various AP= Is accepting both symbols and strings. = Returning fstrings for both of these methods could significantly reduce all= ocations, as well as sligthly reduce retention as it would reduce some dupl= ications. Also, more and more Ruby APIs are now returning fstrings. `frozen_string_li= teral`AFAIK should become the default some day, string used as hash keys ar= e now automatically interned as well. ### Backward compatibilty = Of course this is not fully backward compatible, it's inevitable that some = code in the wild is mutating the strings returned by these methods, but I d= o believe it's a rare occurence, and easy to fix. = ### Implementation I implemented it here: https://github.com/ruby/ruby/pull/2175 -- = https://bugs.ruby-lang.org/ Unsubscribe: