New submission from Alexander Belopolsky <belopol...@users.sourceforge.net>:
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. ---------- components: Interpreter Core files: set-add.diff keywords: patch messages: 94595 nosy: belopolsky severity: normal status: open title: One obvious way to do interning type: feature request Added file: http://bugs.python.org/file15218/set-add.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7224> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com