a list-like type with better asymptotic performance and similar performance on small lists
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/
>>> from blist import * >>> x = blist() # 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.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|blist-0.9.14-py2.5-cygwin-1.5.25-i686.egg (92.3 kB) Copy SHA256 hash SHA256||Egg||2.5|
|blist-0.9.14-py2.5-linux-i686.egg (90.9 kB) Copy SHA256 hash SHA256||Egg||2.5|
|blist-0.9.14-py2.6-linux-i686.egg (91.4 kB) Copy SHA256 hash SHA256||Egg||2.6|
|blist-0.9.14.tar.gz (102.9 kB) Copy SHA256 hash SHA256||Source||None|
|blist-0.9.14.win32-py2.6.exe (93.3 kB) Copy SHA256 hash SHA256||Windows Installer||2.6|
|blist-0.9.14.win32-py3.0.exe (222.3 kB) Copy SHA256 hash SHA256||Windows Installer||3.0|