[Python-Dev] Implementing (parts of) copy module in C

Rasmus Villemoes rv at rasmusvillemoes.dk
Tue Nov 1 17:56:05 EDT 2016


First, apologies if this isn't the appropriate list; I trust I'll be
nudged in the right direction.

I'm using (and contributing to) an application which spends a
significant part of its startup time calling copy.deepcopy, so I thought
I'd try to write a C extension to speed this up. Aside from avoiding the
interpreter overhead, we should also save some time by having access to
pre-sizing the containers.

My plan is to let the C code handle the [at least in my case] most
common stuff - atomic types, dicts, lists, tuples etc., while falling
back to the python implementation for the stuff that's inconvenient to
do in C, or which just hasn't been done yet - this allows a simple
piecemeal approach.

Since my main use case runs on 2.7 only, I've started from the 2.7
branch, and have some working code (passes the test suite, speedup
between 3x-30x depending on the data structure). Before spending time
forward-porting this to Python 3, I'd like to hear if there's any
interest in it? I would of course also be very interested in getting it
into 2.7.x, but I assume that's impossible(?).

Where/how should RFC patches be posted?

Thanks,
Rasmus




More information about the Python-Dev mailing list