[Python-3000] How to override io.BytesIO and io.StringIO with their optimized C version?

Christian Heimes lists at cheimes.de
Wed Dec 26 22:50:03 CET 2007


Alexandre Vassalotti wrote:
> I started to play again with the _bytesio and _stringio modules I
> created, during last summer. Right now, I am mostly porting my changes
> to the current trunk. If all goes well, the modules should be ready to
> merged in the trunk by this week. (question: How should this be done?
> Should I just bundle a set of patches and put on the tracker?)

Merry Christmas Alex!

You could also create a branch. I find a branch more convenient for
large changes like your io optimization. But I'm only a junior core
developer and the seniors or your dictator might think different. ;)

> However, I found a little problem which I am not sure how to fix
> properly. Early during the interpreter initialization process, the
> _bytesio and _stringio modules seems to be unavailable for some
> unknown reason. And since io.py is imported before the modules become
> available, this causes io.py to always use the Python version of
> BytesIO and StringIO. So my question is, how should I override
> io.BytesIO and io.StringIO with their optimized C version? My first
> thought is to override the module in site.py, but I am not sure yet if
> this the right thing to do.

How did you register the optimized versions? Did you add them to
_PyImport_Inittab in Modules/config.c? Modules in _PyImport_Inittab are
available before the io module is loaded.

Christian


More information about the Python-3000 mailing list