[Python-ideas] Ideas for improving the struct module

2017-01-18 Thread Elizabeth Myers
Hello, I've noticed a lot of binary protocols require variable length bytestrings (with or without a null terminator), but it is not easy to unpack these in Python without first reading the desired length, or reading bytes until a null terminator is reached. I've noticed the netstruct library (ht

Re: [Python-ideas] PEP 538: Coercing the legacy C locale to C.UTF-8

2017-01-18 Thread Xavier de Gaye
> On Android, the locale settings are of limited relevance (due to most > applications running in the UTF-16-LE based Dalvik environment) and there's > limited value in preserving backwards compatibility with other locale aware > C/C++ components in the same process (since it's a relatively new ta

Re: [Python-ideas] Ideas for improving the struct module

2017-01-18 Thread Daniel Spitz
+1 on the idea of supporting variable-length strings with the length encoded in the preceding packed element! Several months ago I was trying to write a parser and writer of PostgreSQL's COPY ... WITH BINARY format. I started out trying to implement it in pure python using the struct module. Due t

Re: [Python-ideas] Ideas for improving the struct module

2017-01-18 Thread Steven D'Aprano
On Wed, Jan 18, 2017 at 04:24:39AM -0600, Elizabeth Myers wrote: > Hello, > > I've noticed a lot of binary protocols require variable length > bytestrings (with or without a null terminator), but it is not easy to > unpack these in Python without first reading the desired length, or > reading byte