[Python-Dev] bin codec + EOF (original) (raw)
tomer filiba tomerfiliba at gmail.com
Fri Apr 21 10:34:44 CEST 2006
- Previous message: [Python-Dev] Google Summer of Code proposal: improvement of long int and adding new types/modules.
- Next message: [Python-Dev] bin codec + EOF
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060421/5772205f/attachment.htm
- Previous message: [Python-Dev] Google Summer of Code proposal: improvement of long int and adding new types/modules.
- Next message: [Python-Dev] bin codec + EOF
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]