[issue12422] When deepcopying, don't store immutable objects in the memo dict
New submission from Alex Gaynor alex.gay...@gmail.com: All storing immutable objects in the memo dict does is slow stuff down, due to having a larger hash table, and on some other Python's causing hilarious levels of GC pressure. Using http://paste.pocoo.org/show/421310/ as a benchmark, CPython get's a 2x speedup on the deepcopy portion, and PyPy a 20x. Patch is attached. -- components: Library (Lib) files: d.diff keywords: patch messages: 139300 nosy: alex priority: normal severity: normal status: open title: When deepcopying, don't store immutable objects in the memo dict versions: Python 2.7, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file22497/d.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12422] When deepcopying, don't store immutable objects in the memo dict
Changes by Carl Friedrich Bolz cfb...@gmx.de: -- nosy: +Carl.Friedrich.Bolz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12422] When deepcopying, don't store immutable objects in the memo dict
Alex Gaynor alex.gay...@gmail.com added the comment: A slightly cleverer version (or less clever, depending on how you approach the issue) that also works with tuples of immutable content. -- Added file: http://bugs.python.org/file22499/d.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12422] When deepcopying, don't store immutable objects in the memo dict
Alex Gaynor alex.gay...@gmail.com added the comment: Switched to using assertIs, as merwok suggested. -- Added file: http://bugs.python.org/file22500/d.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12422] When deepcopying, don't store immutable objects in the memo dict
Alex Gaynor alex.gay...@gmail.com added the comment: Amaury points out: this is not strictly about immutable objects, but rather objects who's deepcopy is themselves (identity-wise), in some (rare I think) cases this could provide a slowdown. Specifically a case of [(1, 2, 3)] * 1 would be slower, because it would review each tuple individually, rather than using the memo'd instance. I suspect this case is not so common (to have the same identity object, who's deepcopy is itself such as a tuple or object with custom __deepcopy__, many times in a deepcopy object graph), but I have no proof of this. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12422] When deepcopying, don't store immutable objects in the memo dict
Roundup Robot devnull@devnull added the comment: New changeset e24ad85e9608 by Benjamin Peterson in branch 'default': don't memoize objects that are their own copies (closes #12422) http://hg.python.org/cpython/rev/e24ad85e9608 -- nosy: +python-dev resolution: - fixed stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12422 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com