[RFC][PERFORMANCE][PYREX][TIRED OF THESE YET?] *fast* walkdirs.
Martin Pool
mbp at canonical.com
Fri Jun 16 01:57:17 BST 2006
On 15/06/2006, at 11:25 PM, Andrew Bennetts wrote:
> Robert Collins wrote:
>> On Wed, 2006-06-14 at 12:17 +1000, Martin Pool wrote:
> [...]
>>>
>>> If possible I'd like them to actually be plugins loaded through the
>>> regular mechanism. They may need to patch themselves into bzr and
>>> perhaps it's not always possible, but something to aim for.
>>
>> I think that that increases the chance of skew in a single users
>> install
>> between their C and python versions, and it does not change the
>> ease or
>> difficulty of testing both implementations : either the thing they
>> replace has a factory where we can control the one used, or it
>> acts like
>> a singleton, and we have to just test one during a test run.
OK, never mind about plugins.
> Why not do it this way: for some feature foo with an optional C
> implementation,
> have a foo.py that simply consists of:
>
> try:
> from _c_foo import *
> except ImportError:
> from _py_foo import *
>
> Where _c_foo would be the "foo" module in C, and _py_foo would be
> the pure
> python fallback. Tests for "foo" can directly access both _c_foo
> and _py_foo
> modules to make sure they both pass. Callers of foo get the C
> version if
> available, and automatically get the python version if not.
I prefer something like spiv's approach, or something along those
lines. It doesn't seem that much harder and does mean that you can
at least name the two modules, if we want to add tests that exercise
both in the future.
--
Martin
More information about the bazaar
mailing list