yeah, i came to realize nothing helpful will ever come out from this list, so i might
as well stop trying. but i have one last thing to try.

i'm really missing a binary codec, just like the hex codec, for doing things like
>>> "abc".encode("bin")
"011000010110001001100011"
>>> "011000010110001001100011".decode("bin")
"abc"

decode should also support padding, either None, "left", or "right", i.e.,
>>> "1".decode("bin") # error
>>> "1".decode("bin", "left) # 00000001
'\x01'
>>> '1'.decode("bin", "right") # 10000000
'\x80'

i've written a codec by myself for that, it's not that complicated, but the problem
is, because it's not in the standard encodings package, i can't distribute code that
uses it easily:
* i have to distribute it with every release, or i'll enter a dependency nightmare.
* i'd have to provide setup instructions for the codec ("put this file in ../encodings")
and rely on user's abilities. it's not that i think my users are incapable of doing so,
but my distro shouldn't rely on my users.
* upgrading more complicated (need to fix several locations)
* i don't want to write intrusive setups. i like to keep my releases as simple as zip
files that the user just needs to extract to /site-packages, with no configuration or
setup hassle. setups are too dangerous imho, you can't tell they if they'd mess up
your configuration.

so i resorted to an encode_bin and decode_bin functions that are included with my
code. of course this codec should be written in c to make it faster, as it's quite a
bottleneck in my code currently.

it's a trivial and useful codec that should be included in the stdlib. saying "you can
write it for yourself" is true, but the same came be said about "hex", which can
even be written as a one-liner: "".join("%02x" % (ord(ch),) for ch in "abc")

so now that it's said, feel free to (-1) it by the millions. don't worry, i will not waste
my or your time anymore.


-tomer
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to