[RFC] TreeTransform and 'iter_files_bytes()'

Aaron Bentley aaron at aaronbentley.com
Wed Mar 25 12:18:21 GMT 2009


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

John Arbash Meinel wrote:
> I was looking over the time for "bzr co" with the new brisbane-core
> formats. And I was surprised to see that the time for "writelines()" was
> 6.6s, when it was only ~1.0s if we had an 'accelerator_tree'.
> 
> It turns out that TreeTransform.create_files(content, ...) is treating
> 'content' as an iterator, and calling "out.writelines(content)".
> 
> However, when you start with Repository.iter_files_bytes() the content
> object is a *string*.

Per the docstring, the content object ("bytes_iterator") is supposed to
be "an iterable of bytestrings for the file".  I named it
"iter_files_bytes" before we were calling sequences of bytes "chunked",
but chunked output was definitely intended.

Of course, a bytestring is an iteratable of bytestrings, so you *can*
argue that the contract is being fulfilled.  But that certainly wasn't
the intent.  I'd have named it iter_files_texts if that were the intent.

> At least, I think that is the easier fix, rather than changing the api
> of "iter_files_bytes()" to return a 'chunked' format. Mostly because it
> is a more significant API change.

The implementation is wrong.  Fix it to return chunked.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknKIQoACgkQ0F+nu1YWqI1FwgCfX+FH/FPpgS9wgIZgmci1+ucR
/YQAnAxka3jWXrpFVg194BRIcOduHhhc
=IvCF
-----END PGP SIGNATURE-----



More information about the bazaar mailing list