ilanschnell/bitarray — Issue #4: bitarray doesn't work with marshal
Author: buchuki
Created: 2012-02-13 18:33:30+00:00
State: open

Dumping a bitarray directly via marshal does not store the correct format:

```python
>>> from bitarray import bitarray
>>> b = bitarray('10001101')
>>> b
bitarray('10001101')
>>> import marshal
>>> s = marshal.dumps(b)
>>> c = marshal.loads(s)
>>> c
'\x8d'
>>> b # for comparison
bitarray('10001101')
```

A workaround is to dump and load mytes:

```python
>>> s = marshal.dumps(b.tobytes())
>>> c = bitarray()
>>> c.frombytes(marshal.loads(s))
>>> c
bitarray('10001101')
>>> b # for comparison
bitarray('10001101')
```
It would be more convenient when marshaling bitarrays stored in lists, dicts, etc if it was not necessary to do this conversion.