[RFC] Repository.get_file_texts API and planning for it
Aaron Bentley
aaron.bentley at utoronto.ca
Wed Aug 15 16:04:29 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John Arbash Meinel wrote:
>> Iterables of bytes is a very convenient one. Text lines is nice only
>> when working with text. File objects have high API demands, but even
>> strings are iterables of bytes.
>
> You've said this in the past, and while I agree it is convenient, it has
> some odd performance characteristics. Specifically (edited for clarity):
I've no doubt it does.
> So while I agree that iterable of bytes is a convenient and very
> adaptable api. We really don't want to be passing a plain string to that
> api.
It is very convenient for test cases, though.
So we can
1. recommend wrapping strings in lists (or maybe tuples-- how fast are
they?)
2. automatically wrap strings in lists/tuples as an optimization.
But I should say that passing in a single string to create_file suggests
that you're not being memory-efficient, because you must have read a
whole file into memory.
So there are other reasons than writelines performance to avoid this in
real code.
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGwxX90F+nu1YWqI0RAmMgAJ48flCDDYylZU/M9bl3vjkVhk8Q6QCfUEPo
2cm7tha+A8WkXzMU21ca1mA=
=0Up0
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list