3👍
If you are currently just using pickle, might I recommend cPickle which is purported to be up to 1000 times faster.
0👍
ultrajson to the rescue!
In [1]: from string import letters
In [3]: import ujson
In [5]: import cPickle as pickle
In [7]: import random
In [8]: def random_string(n=10): return ''.join([random.choice(letters) for _ in xrange(n)])
In [9]: DATA = {random_string(): list(range(1000)) for _ in xrange(1000)}
In [12]: %timeit -r 3 -n 100 ujson.dumps(DATA)
100 loops, best of 3: 89.2
In [13]: %timeit -r 3 -n 100 pickle.dumps(DATA)
100 loops, best of 3: 285 ms per loop
- [Django]-Django – cannot unpack non-iterable ManyRelatedManager object
- [Django]-Testing abstract models – django 2.2.4 / sqlite3 2.6.0
Source:stackexchange.com