[Python-Dev] Choosing a best practice solution for Python/extension modules

Daniel Stutzbach daniel at stutzbachenterprises.com
Fri Feb 20 21:31:26 CET 2009


On Fri, Feb 20, 2009 at 1:44 PM, Brett Cannon <brett at python.org> wrote:

> Now, from what I can tell, Antoine is suggesting having _pyio and a _io and
> then io is simply:
>
>     try: from _io import *
>     except ImportError: from _pyio import *
>
> That works for testing as you can then have test classes have an attribute
> for the module to use and then create two subclasses which set what module
> to use (kind of like how test_warnings currently does it). But this only
> really works for complete module replacements, not modules like pickle where
> only key portions have been rewritten (which happens more often than the
> complete rewrite).
>

A slight change would make it work for modules where only key functions have
been rewritten.  For example, pickle.py could read:

from _pypickle import *
try: from _pickle import *
except ImportError: pass

--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090220/7aeeb92e/attachment.htm>


More information about the Python-Dev mailing list