[BUG][0.12] bench_bundle imports the wrong 'read_bundle'

John Arbash Meinel john at arbash-meinel.com
Fri Oct 27 16:16:47 BST 2006


Martin Pool wrote:
> On 24 Oct 2006, John Arbash Meinel <john at arbash-meinel.com> wrote:
>> The bench_bundle tests that were recently added are importing the wrong
>> 'read_bundle' function. So when I updated bzr to lazily import the
>> function, it now is grabbing the lazy object.
>>
>> The attached patch gets the benchmark tests running again. And changes
>> the imports to import as private functions to help avoid this problem in
>> the future.
>>
>> Some of them are slow enough we should probably be skipping them. I
>> thought we weren't running the 1000 revision tests, but it seems those
>> did get merged. Martin was just running the tests, and 1 of them was
>> taking 149653319ms or ~41 hours to complete a single test on our
>> benchmark machine. Which is not really what we want to be testing. A
>> couple minutes is a good time, an hour is reasonable, but beyond that
>> isn't a very usable test. Maybe it allows us to show just how much
>> faster we can become, but it isn't something we want to run often.
> 
> +1, jinx.
> 

...

> I'm in favour of changing the imports to prevent the problem, but would
> it be more consistent to just import serializer and say
> serializer.read_bundle.
> 
> 

Well, there is a small conflict in how python does importing, and how a
lazy_importer would try to do this. Basically if you have a module and
you do:

module/__init__.py:

  from module import submodule

First, you can't do:

import module.submodule

Because 'module' hasn't been defined yet, so the import logic starts
either puking or doing weird loops. The "from <self> import other" seems
to actually work as long as you do it *after* anything that 'other' needs.

However, when you import a variable into the local namespace, future
calls to:

from module import submodule

Get the attribute from that module, rather than a sub-module. So if I did:

module/__init__.py:

   variable = 10

Then I can do "from module import variable" and get the variable = 10.
*However* if I also have a python file named 'variable.py', then doing:

from module import variable

is different that

import module.variable

or

from module.variable import ???

It is because 'from X import Y' can be ambiguous. Anyway, because of all
of this, you have to be careful when importing a child into a parent
module. Especially with lazy importing. But the attached patch should
work fine, and is what I'm merging.

John
=:->


-------------- next part --------------
A non-text attachment was scrubbed...
Name: bundle_readme_fixes.patch
Type: text/x-patch
Size: 2240 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061027/cf23a2f9/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061027/cf23a2f9/attachment.pgp 


More information about the bazaar mailing list