[MERGE] import both c-extension and python module with the same name for testing

Alexander Belchenko bialix at ukr.net
Mon Aug 6 21:33:47 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Today I had conversation on IRC with spiv and Peng.
We discussed with spiv my pyrex bencode and then started to discuss
new strategy of bzrlib for pyrex/c extensions modules.

Because we want to tests all versions (python and pyrex) separately,
John for his _knit_load_data pyrex extension did such things:

1) python version of module named _load_data_py.py
2) pyrex version of module named _load_data_c.pyx
3) Then importing one of them (in knit.py):

try:
    from bzrlib._knit_load_data_c import _load_data_c as _load_data
except ImportError:
    from bzrlib._knit_load_data_py import _load_data_py as _load_data

If we need this zoo only for testing, then we could provide more complex
importing scheme for test suite, but simplify core code.

Instead of keeping py and c versions with separate module names, we could
create them with the same module name (_load_data.py and _load_data.pyx for example
above). At runtime Python interpreter will import c-extension first if any
presents. And for testing we need to use special approach to import
python version. This patch provide mechanism to achieve this goal.

The main reason for this patch is faster import of modules: we let to Python
interpreter choose appropriate version of module and get rid of
try/except ImportError construct.

Andrew, what you think about my patch?

- --
[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGt4WrzYr338mxwCURApFCAKCWQra8grkf6osPGdVnDWMPiyfblQCeJmVF
fCjCUeQu/KkZOJuGyHlYoqA=
=ZRI/
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: load_py_and_c.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20070806/7814be48/attachment.diff 


More information about the bazaar mailing list