Message87567
Well, yes and no.
I agree that it is annoying to have to add another parameter to get a
returning tuple. But you have to weigh that against adding another
conveinence API.
On the other hand, I think the offset argument is quite convenient. If
we were to add a "decompress2" function, I would like to keep the
offset because it removes the extra overhead of having to create a
temporary buffer object, at no extra cost.
Also, note that your example code becomes more complex, for a loop.
You would need to:
results = []
used =0
while used<len(source):
r, u = zlib.decompress2(buffer(source, used))
used += u
results.append(r)
as opposed to:
r, used = zlib.decompress2(source, used)
results.append(r)
You have to make sure you add the buffer's hidden offset to the output
offset.
There is a third option. The "offset" could be a list containg the
offset in its 0th position, a sort of "byref" passing, but that is not
in the general Python spirit, is it?
This would give us the loop:
o = [0]
while len(source)>o[0]
results.append(zlib.decompress(source, offset=offsetlist)) |
|
Date |
User |
Action |
Args |
2009-05-11 08:56:25 | kristjan.jonsson | set | recipients:
+ kristjan.jonsson, gregory.p.smith, pitrou, rbcollins |
2009-05-11 08:56:25 | kristjan.jonsson | set | messageid: <1242032185.57.0.437214445534.issue5804@psf.upfronthosting.co.za> |
2009-05-11 08:56:24 | kristjan.jonsson | link | issue5804 messages |
2009-05-11 08:56:23 | kristjan.jonsson | create | |
|