Speed III

Serialisation and back again is generally an expensive operation. This is a consequence of weak typing. Sometimes writing custom serialisers for transporting is worthwhile.

  • Pickle (well, cPickle) is the most general thing with a knowledge of Python (so easy to use). It is also quite slow and needs careful watching where untrusted data can be passed in.

    Remember: Unpickling random data is not safe!

  • For just flattening sequences, special classes (lists of attributes) and dictionaries, special purpose flattening code is better.

  • Converting BCD values into Python numbers was sped up approximately two orders of magnitude by rewriting in carefully crafted C.