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-October/105024.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
Fri Oct 29 12:15:04 CEST 2010
> Actually I would like code like
>   s = socket()
>   ...
>   header = struct.unpack("i", s)
> 
> In other words, struct should interact with files/streams directly, instead of 
> requiring me to first read a chunk who's size I manually have to determine 
> etc.

That is easy to achieve using the existing API:

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.

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