[BUG] transport/memory.py doesn't handle strings

Robey Pointer robey at lag.net
Wed Oct 19 01:51:55 BST 2005


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


On 18 Oct 2005, at 17:39, Aaron Bentley wrote:

> Robert Collins wrote:
>
>> On Tue, 2005-10-18 at 16:45 -0500, John A Meinel wrote:
>>
>>> There are a couple of changes that should be made to the
>>> transport/memory.py implementation.
>>> First, most of the "put" functions can take either a file-like  
>>> object, or
>>> a string. Which means that MemoryTransport.put() shouldn't just call
>>> read(), it should also check to see if it is already a string.  
>>> (Either
>>> that, or we can change the api if you really prefer).
>>
>> I think that the ambigious api is very strange. I'd much rather have
>> explict put_stream, put_string etc.
>
> I'd rather have put_iterable, because files are iterables of strings,
> but so are lists, and so are strings.  So all of these have the  
> same result:
>
> put_iterable('hello')
> put_iterable(['hel','lo'])
> put_iterable(StringIO('hello'))

Wouldn't that first one be terribly inefficient though? :)   
(Iterating a string gives you one byte at a time.)

It also looks like iterating over a binary file gives you a single  
string with the entire contents of the file.  Yuck. :(  My coworkers  
have been known to checkin 100+MB tarballs, and you don't want to  
load that all into memory at once.

robey

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)

iD8DBQFDVZi2QQDkKvyJ6cMRAipTAKDgEBFQseG+pKCgG9L8R9paBvZihQCffvi3
Wx5MNZ2F0Qg17f7i0uU3L2s=
=UQ/I
-----END PGP SIGNATURE-----




More information about the bazaar mailing list