[Python-ideas] Ideas for improving the struct module
Paul Moore
p.f.moore at gmail.com
Fri Jan 20 11:59:45 EST 2017
On 20 January 2017 at 16:51, Elizabeth Myers <elizabeth at interlinked.me> wrote:
> Should I write up a PEP about this? I am not sure if it's justified or
> not. It's 3 changes (calcsize and two format specifiers), but it might
> be useful to codify it.
It feels a bit minor to need a PEP, but having said that did you pick
up on the comment about needing to return the number of bytes
consumed?
str = struct.unpack('z', b'test\0xxx')
How do we know where the unpack got to, so that we can continue
parsing from there? It seems a bit wasteful to have to scan the string
twice to use calcsize for this...
A PEP (or at least, a PEP-style design document) might capture the
answer to questions like this. OTOH, the tracker discussion could
easily be enough - can you put a reference to the bug report here?
Paul
More information about the Python-ideas
mailing list