a list-like type with better asymptotic performance and similar performance on small lists
Project description
The BList is a type that looks, acts, and quacks like a Python list, but has better performance for for modifying large lists.
Earlier versions of BList were also slower for large lists that never change length, but this is no longer true as of version 0.9.6, which features amortized worst-case O(1) getitem and setitem operations.
With that disclaimer out of the way, here are some of the use cases where the BLists is dramatically faster than the built-in list:
Insertion into or removal from a large list (O(log n) vs. O(n))
Taking large slices of large lists (O(log n) vs O(n))
Making shallow copies of large lists (O(1) vs. O(n))
Changing large slices of large lists (O(log n + log k) vs. O(n + k))
Multiplying a list to make a large, sparse list (O(log k) vs. O(kn))
You’ve probably noticed that we keep referring to “large lists”. For small lists, BLists and the built-in list have very similar performance.
So you can see the performance of the BList in more detail, several performance graphs available at the following link: http://stutzbachenterprises.com/blist/
Example usage:
>>> from blist import * >>> x = blist([0]) # x is a BList with one element >>> x *= 2**29 # x is a BList with > 500 million elements >>> x.append(5) # append to x >>> y = x[4:-234234] # Take a 500 million element slice from x >>> del x[3:1024] # Delete a few thousand elements from x
For comparison, on most systems the built-in list just raises MemoryError and calls it a day.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for blist-0.9.14-py2.6-linux-i686.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f9b40a2550aaabfacfa2ef673361885616474a1c8f0859e54b82950c7e6c714 |
|
MD5 | 43b07eace21c70bbb8596ebff2924f8c |
|
BLAKE2b-256 | e8f397699b26faa1679210dc977ec935dd3c8b4e940d35c3a606c19f0e3d3c6c |
Hashes for blist-0.9.14-py2.5-linux-i686.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36f602762c0a07c1d92bbbb9c0926eb11ad1e60a6d7774daa98d7780136822ac |
|
MD5 | 5c86e7bb1b5594e95d498e139f5db544 |
|
BLAKE2b-256 | 0fea52bf870ef85b38b5ac29b95a3569e99c4d5b64fcacd77ba90c037b475f11 |
Hashes for blist-0.9.14-py2.5-cygwin-1.5.25-i686.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | abb63f89d19a0a00b3712b3f3009b8b443116d9d3b64b35fde6a7283f0fc3b20 |
|
MD5 | 7e11efea5e2344d770b5c56c5a716b74 |
|
BLAKE2b-256 | 8eb691f0ffc005c30d72d49f33e02637c37858d9577441b515200446db61c136 |