Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm puzzled by your comment that there's very little degradation using deepcopy everywhere. Your numbers demonstrate quite the opposite.


Thanks for noticing - I got my numbers completely off. When I ran the benchmark on my machine it turns out it was still using the original copy.

One way to catch deepcopy bugs might be to create an autocopy function which can detect if it is a 'shallow' object and use copy, or if not use deepcopy.

I am going to try and write an implementation that doesn't slow it down too much. It might be worthwhile since copy bugs are so common in Python projects.


I wonder whether it would be possible to optimise the Python interpreter to make deep copies copy-on-write. I suppose that would involve a lot of work for relatively little gain.


I remember that being mentioned in a PEP somewhere but it never got implemented. It might be worth implementing copy in C with copy-on-write to bring some of those benchmark numbers down.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: