[BUG] transport/memory.py doesn't handle strings
Robey Pointer
robey at lag.net
Thu Oct 20 02:17:04 BST 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 19 Oct 2005, at 15:50, John A Meinel wrote:
> Robey Pointer wrote:
>
>> On 18 Oct 2005, at 23:17, Aaron Bentley wrote:
>>
>>>>> Yuck. :( My coworkershave been known to checkin 100+MB tarballs,
>>>>> and you don't want to load that all into memory at once.
>>>>
>>>> We already do. Look at osutils.pumpfile.
>>
>> Ouch! Well just to prove that I'm not always just sniping from the
>> sidelines, here's a small patch to fix that one. :)
>
> What is wrong with:
>
> chunk = file.read(blocksize)
> while chunk:
> tofile.write(chunk)
> chunk = file.read(blocksize)
>
> I realize generators are spiffy, it just seems like overkill. (though
> filereader() might be generally useful)
Yeah it's just a bit of code I copy around from project to project as
I need it. The main point was to prove that you don't have to (and
should not) load an entire file into memory just to stream it
somewhere else. :)
robey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)
iD8DBQFDVvATQQDkKvyJ6cMRArmiAKC8QV12VW6pq3yvi9Qv18NCgX+SHQCgp8qb
nELTSyU7rX5hhs9AOBnnwGE=
=/6Rb
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list