[Python-ideas] a new bytestring type?

Masklinn masklinn at masklinn.net
Mon Jan 6 12:59:13 CET 2014


On 2014-01-06, at 11:57 , Stephen J. Turnbull <stephen at xemacs.org> wrote:
> Geert Jansen writes:
> 
>> I'm not missing a new type, but I am missing the format method on the
>> binary types.
> 
> I'm curious about precisely what your use cases are, and just what
> formatting they need.

Building up protocol output, especially (but not solely) ascii-based
ones, from existing or computed parts. Basically the same reasons behind
Erlang's bit syntax (on the building side thereof):
http://www.erlang.org/doc/programming_examples/bit_syntax.html

Essentially a partial and more readable (especially more readable)
version of what `struct` provides, and one in which the "pattern" can
contain literal constant content. `struct` is nice, but it doesn't scale
very well to big binary creation, and it's fairly horrible when part of
the output is constant as constant parts *still* have to be patterned
and injected as parameters.

Also, no support for keyword arguments.


More information about the Python-ideas mailing list