A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-November/105132.html below:

[Python-Dev] new buffer in python2.7

[Python-Dev] new buffer in python2.7 [Python-Dev] new buffer in python2.7"Martin v. Löwis" martin at v.loewis.de
Mon Nov 1 07:22:14 CET 2010
>> def read_and_unpack(stream, format): 
>>   data = stream.read(struct.calcsize(format))
>>   return struct.unpack(format, data)
>> 
>>> Otherwise, I'm +1 on your suggestion, avoiding copying is a good
>>> thing.
>> 
>> I believe my function also doesn't involve any unnecessary copies.
> You just moved your copying down one level into stream.read(). This
> magic function must be implemented by possibly concatenating
> several "socket.recv()" calls.
> This invariably involves data copying, either by "".join() or
> stringio.write()

Assuming there are multiple recv calls. For a typical struct, all data
will come out of the stream with a single recv. so no join will be
necessary.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4