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/128890.html below:

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

[Python-Dev] sys.intern should work on bytesHrvoje Niksic hrvoje.niksic at avl.com
Mon Sep 23 10:03:12 CEST 2013
On 09/20/2013 06:50 PM, PJ Eby wrote:
> On Fri, Sep 20, 2013 at 9:54 AM, Jesus Cea <jcea at jcea.es> wrote:
>> Why str/bytes doesn't support weakrefs, beside memory use?
>
> The typical use case for weakrefs is to break reference cycles,

Another typical use case, and the prime reason why languages without 
reference counting tend to introduce weak references, is managing object 
caches with automatic disposal of otherwise unused items. Such a cache 
is rarely necessary for primitive objects, so Python's choice to spare 
memory for weakrefs is quite justified.

However, if one wanted to implement their own sys.intern(), inability to 
refer to strings would become a problem. This is one reason why 
sys.intern() directly fiddles with reference counts instead of reusing 
the weakref machinery. (The other of course being that intern predates 
weakrefs by many years.)

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