[win32] Permission denied in fancy_rename
John Arbash Meinel
john at arbash-meinel.com
Wed May 3 18:27:57 BST 2006
Aaron Bentley wrote:
> John Arbash Meinel wrote:
>> Anyway, I think get_bytes/put_bytes is good, but we should think about
>> the memory impact.
>
> Perhaps get_bytes/put_bytes should take/produce an iterable? That would
> ensure a low memory impact.
>
> Strings, files, and string iterators are all iterables of strings, and
> we can special-case files and strings if we want.
>
> Aaron
>
You've been trying to get iterators for a while now, and this might just
be the place for it.
We certainly could have the default 'get_bytes' something like:
def get_bytes(relpath):
fp = self.get(relpath)
chunk = fp.read(32768)
while chunk:
yield chunk
chunk = fp.read(32768)
And if we have some sort of a string, we can either do:
def get_bytes(relpath):
s = something
return [s]
Or some sort of split based on length.
http could just yield chunks from the urllib.urlopen() file. (It seems
to be a wrapper named addinfourl (add info url) around a
socket.makefile() call).
sftp could likewise return chunks from the SFTP file.
Then the naive put_bytes could become:
def put_bytes(relpath, bytes, mode=None):
buffer = StringIO()
for b in bytes:
buffer.write(b)
self.put(relpath, buffer, mode=mode)
I could see special casing "put_bytes" for strings so we don't iterate
over every character. Simply wrapping it in a list is probably enough.
John
=:->
-------------- 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/20060503/831fb3d9/attachment.pgp
More information about the bazaar
mailing list