8:873c435a2a0d
Anton Shestakov <engored@ya.ru>, Thu, 17 Jan 2013 22:11:45 +0900
Docs for bitarray experiment.

next change 9:ea1f77aa6c79

sets-to-strings-via-bitarrays/README.md

Permissions: -rw-r--r--

Other formats: Feeds:
Today's just-for-fun experiment: encode a set of integers (usually seen as
`?whtvr=3,7,8,9,11...` in urls) into a string. Sure, just doing `','.join`
on a set works, but the result's ugly¹. Such stuff in urls was, I believe,
one of the reasons Opera 11 decided to hide all parameters in address bar
by default. Urls look better without cruft.
So instead, I'd like to have something short and
with letters in it. Something that looks like it could be a part of those
"shortened urls" (i.e. <http://goo.gl/Gmzqv>²).
How about encoding the set with base64?
:::python
'3,7,8,9,11,12,13,16,23,27,30,33'.encode('base64')
# 'Myw3LDgsOSwxMSwxMiwxMywxNiwyMywyNywzMCwzMw==\n'
Gah! This just doesn't work. But hey, what we encoded here is not *the set*,
it's a *string representation* of the set! How about ditching this string
and think of other structure to represent sets. Hmm, what could it be?
Hint: it's in the experiment title, duh.
¹: although it's also easier to debug
²: you can check real location without visiting short url with
`curl --head <url> | grep Location`
Requirements
------------
Python (2 or 3), [bitarray].
[bitarray]: http://pypi.python.org/pypi/bitarray/