improvement for copy.deepcopy : no memo for immutable types

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Fri Jul 16 09:59:31 EDT 2010


On Fri, 16 Jul 2010 05:45:50 -0700, Inquisitive Scientist wrote:

> I am having problems with running copy.deepcopy on very large data
> structures containing lots of numeric data:
[...]
> This seems perfectly safe, should speed things up, keep the memo dict
> smaller, and be easy to add. Can someone add this to copy.py or point me
> to the proper procedure for requesting this change in copy.py?

These are the minimum steps you can take:

(1) Go to the Python bug tracker: http://bugs.python.org/

(2) If you don't already have one, create an account.

(3) Create a new bug report, explaining why you think deepcopy is buggy, 
the nature of the bug, and your suggested fix.

If you do so, it might be a good idea to post a link to the bug here, for 
interested people to follow up.

However doing the minimum isn't likely to be very useful. Python is 
maintained by volunteers, and there are more bugs than person-hours 
available to fix them. Consequently, unless a bug is serious, high-
profile, or affects a developer personally, it is likely to be ignored. 
Sometimes for years. Sad but true.

You can improve the odds of having the bug (assuming you are right that 
it is a bug) fixed by doing more than the minimum. The more of these you 
can do, the better the chances:

(4) Create a test that fails with the current code, following the 
examples in the standard library tests. Confirm that it fails with the 
existing module.

(5) Patch the copy module to fix the bug. Confirm that the new test 
passes with your patch, and that you don't cause any regressions (failed 
tests).

(6) Create a patch file that adds the new test and the patch. Upload it 
to the bug tracker.

There's no point in writing the patch for Python 2.5 or 3.0, don't waste 
your time. Version 2.6 *might* be accepted. 2.7 and/or 3.1 should be, 
provided people agree that it is a bug.

If you do all these things -- demonstrate successfully that this is a 
genuine bug, create a test for it, and fix the bug without breaking 
anything else, then you have a good chance of having the fix accepted.

Good luck! Your first patch is always the hardest.



-- 
Steven



More information about the Python-list mailing list