[issue34386] Expose a dictionary of interned strings in sys module

2018-08-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I concur with Ronald. Using a dict instance is an implementation detail. CPython could use a dict, a set, a hashtable implementation from Modules/hashtable.c, or the HAMT implementation from Python/hamt.c. Other Python implementations can have other option

[issue34386] Expose a dictionary of interned strings in sys module

2018-08-13 Thread Ronald Oussoren
Ronald Oussoren added the comment: IMHO we shouldn't expose the intern dictionary without there being a clear, and good enough, use case for doing so. Exposing the dictionary decreases implementation flexibility, and increases requirements on other implementations. One example of the form

[issue34386] Expose a dictionary of interned strings in sys module

2018-08-12 Thread Artem Golubin
Artem Golubin added the comment: Thank you, I agree. I can't come up with practical use cases other than my curiosity. Is it possible to somehow expose the dictionary in the debug build of Python? Currently, there is no way to access it from the interpreter even with ctypes. -- __

[issue34386] Expose a dictionary of interned strings in sys module

2018-08-12 Thread Ronald Oussoren
Ronald Oussoren added the comment: Another reason for not wanting write access to the sys.intern dictionary is that this dictionary does not own references to its keys and values. -- ___ Python tracker

[issue34386] Expose a dictionary of interned strings in sys module

2018-08-12 Thread Raymond Hettinger
Raymond Hettinger added the comment: I wouldn't want a user to be able to mutate the dictionary directly (otherwise, non-strings could be added). -- nosy: +rhettinger ___ Python tracker

[issue34386] Expose a dictionary of interned strings in sys module

2018-08-12 Thread Ronald Oussoren
Ronald Oussoren added the comment: Could you explain why this would be useful? -- nosy: +ronaldoussoren ___ Python tracker ___ ___

[issue34386] Expose a dictionary of interned strings in sys module

2018-08-12 Thread Artem Golubin
New submission from Artem Golubin : Python provides an ability to intern strings (sys.intern). It would be useful to expose a read-only dictionary of interned strings to the Python users so we can see what kind of strings are interned. It takes minimal changes since internally it's just a di