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.

Author belopolsky
Recipients belopolsky
Date 2009-10-28.01:05:20
SpamBayes Score 2.1706908e-10
Marked as misclassified No
Message-id <1256691929.12.0.04518648136.issue7224@psf.upfronthosting.co.za>
In-reply-to
Content
Attached patch implements python-ideas proposal to return added or 
existing element from set.add().  See 
http://mail.python.org/pipermail/python-ideas/2009-October/006491.html .

In addition this patch contains a reimplementation of issue1507011 using 
new behavior of set_add.

The two changes are independent an I would submit them separately if I 
was more optimistic that any would be accepted. :-)

This submission is mostly for the benefit of users with applications 
that create huge number of interned strings.  Since the patch saves 8 
bytes for each interned string, such application can see appreciable 
memory savings.

I don't have such application and my tests show no difference between 
patched and stock python.  (For a data point, on start up stock python 
creates about 2,000 interned strings.)

My own motivation for writing this patch was the same as for issue1507011: the code that uses a set to store interned strings is more  
straightforward than code that uses a dict that stores strings twice, 
both as key and value.
History
Date User Action Args
2009-10-28 01:05:30belopolskysetrecipients: + belopolsky
2009-10-28 01:05:29belopolskysetmessageid: <1256691929.12.0.04518648136.issue7224@psf.upfronthosting.co.za>
2009-10-28 01:05:27belopolskylinkissue7224 messages
2009-10-28 01:05:24belopolskycreate