(original) (raw)
On Fri, Feb 20, 2009 at 13:15, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
But that's only at import time and that is rather minor compared to other execution costs.
See the other thread I started on discussing best practices for this, but this won't work for modules where only part of the implementation has an optimized version in an extension module (e.g. pickle).
-Brett
Steven D'Aprano wrote:Also, won't foo.py be wasting time in most cases by
Currently, if I want to verify that (say) cFoo and Foo do the same thing, or compare their speed, it's easy because I can import the modules separately.
defining python versions that get overwritten?
But that's only at import time and that is rather minor compared to other execution costs.
Instead of defining things directly in foo.py, maybe it
should do
try:
from cFoo import \*
except ImportError:
from pyFoo import \*
Then the fast path will be taken if cFoo is available,
and you can directly import cFoo or pyFoo if you want.
See the other thread I started on discussing best practices for this, but this won't work for modules where only part of the implementation has an optimized version in an extension module (e.g. pickle).
-Brett