You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
defisinterned(s):
returnsys.intern(s) iss
But it has a side effect -- it interns a string if it is not equal to an already interned string.
Activity
serhiy-storchaka commentedon Aug 13, 2018
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:
But it has a side effect -- it interns a string if it is not equal to an already interned string.
tiran commentedon Aug 13, 2018
I'd prefer to have this as an internal API, either sys._isinterned() or as a helper method in testcapi.
brettcannon commentedon Aug 14, 2018
I agree with Christian; this is an implementation detail so it should be flagged as private/internal somehow.
warsaw commentedon Aug 15, 2018
Agreed it should be non-public, but can we please call it sys._is_interned()?
serhiy-storchaka commentedon Aug 19, 2018
Thank you all for the feedback. The function is renamed to sys._is_interned() and documented as optional.