Raymond Hettinger added the comment:
One suggestion:
def _deepcopy_list(x, memo, deepcopy=deepcopy):
y = []
memo[id(x)] = y
y[:] = [deepcopy(a, memo) for a in x]
return y
This looks nicer and should run faster by taking advantage of the LIST_APPEND
opcode.
It should be noted that the core concept of the patch is all about the
minimizing the calling overhead of the copying operation (the cost to call
type(x) and the overhead in the type constructors for parsing the positional
and keyword arguments). When it comes to actually copying the data in the
containers, there underlying code to do the copying is the same for both the
patched and unpatched version (that is why you see a speed-up for copying empty
containers and almost no change for containers that have data in them).
----------
nosy: +rhettinger
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26167>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com