This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add sys.isinterned()
Type: enhancement Stage: patch review
Components: Interpreter Core Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: barry, brett.cannon, christian.heimes, rhettinger, ronaldoussoren, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-08-13 10:24 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 8755 open serhiy.storchaka, 2018-08-13 10:29
Messages (5)
msg323473 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-13 10:24
I need to test whether the string is interned for Python implementations of marshal.dumps(). It is easy to do in C, and I suggest to expose this functionality to Python.

Currently you can test if the string is interned using the following function:

    def isinterned(s):
        return sys.intern(s) is s

But it has a side effect -- it interns a string if it is not equal to an already interned string.
msg323474 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2018-08-13 11:07
I'd prefer to have this as an internal API, either sys._isinterned() or as a helper method in testcapi.
msg323539 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2018-08-14 20:43
I agree with Christian; this is an implementation detail so it should be flagged as private/internal somehow.
msg323545 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-08-15 00:13
Agreed it should be non-public, but can we please call it sys._is_interned()?
msg323744 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-08-19 06:55
Thank you all for the feedback. The function is renamed to sys._is_interned() and documented as optional.
History
Date User Action Args
2022-04-11 14:59:04adminsetgithub: 78573
2022-02-09 05:52:10methanelinkissue46688 superseder
2018-08-19 06:55:15serhiy.storchakasetmessages: + msg323744
2018-08-15 00:13:57barrysetnosy: + barry
messages: + msg323545
2018-08-14 20:43:28brett.cannonsetnosy: + brett.cannon
messages: + msg323539
2018-08-13 11:07:02christian.heimessetnosy: + christian.heimes
messages: + msg323474
2018-08-13 10:29:27serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request8231
2018-08-13 10:24:33serhiy.storchakacreate