[MERGE] import both c-extension and python module with the same name for testing
robertc at robertcollins.net
Tue Aug 7 00:37:08 BST 2007
On Mon, 2007-08-06 at 23:33 +0300, Alexander Belchenko wrote:
> -----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):
> 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.
Well, theres no need for other modules to import the fastpath code. In
actual fact I had this basic approach in my very early pyrex
experiments, but we moved away from it.
> 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.
I don't believe there will be any difference in performance when the C
version is present. I'd like to see test results on the performance
difference when the C version is not present.
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070807/6bcda99e/attachment-0001.pgp
More information about the bazaar