A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-September/128806.html below:

[Python-Dev] sys.intern should work on bytes

[Python-Dev] sys.intern should work on bytes [Python-Dev] sys.intern should work on bytesVictor Stinner victor.stinner at gmail.com
Fri Sep 20 14:04:11 CEST 2013
2013/9/20 Jesus Cea <jcea at jcea.es>:
> """
> sys.intern(b'12121212')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: must be str, not bytes
> """
>
> I wonder why.

Intern strings optimize dictionary lookup. In Python 3, most
dictionaries use str keys (ex: __dict__ of classes).

What would you be the use case of interned bytes objets?

Victor
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4