Skip to main content

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. For small lists (fewer than 128 elements), BLists and the built-in list have very similar performance.

Here are some of the use cases where the BLists asymptotically outperforms the built-in list:

Use Case

BList

list

Insertion into or removal from a list

O(log n)

O(n)

Taking slices of lists

O(log n)

O(n)

Making shallow copies of lists

O(1)

O(n)

Changing slices of lists

O(log n + log k)

O(n+k)

Multiplying a list to make a sparse list

O(log k)

O(kn)

Maintain a sorted lists with bisect.insort

O(log**2 n)

O(n)

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.

Installation instructions

Python 2.5 or higher is required. If building from the source distribution, the Python header files are also required. In either case, just run:

python setup.py install

The BList module will be installed in the ‘site-packages’ directory of your Python installation. (Unless directed elsewhere; see the “Installing Python Modules” section of the Python manuals for details on customizing installation locations, etc.).

If you downloaded the source distribution and wish to run the associated test suite, you can also run:

python setup.py test

which will verify the correct installation and functioning of the package. The tests regrettably do not work on Python 3.

Feedback

We’re eager to hear about your experiences with the BList. Please send all feedback and bug reports to daniel@stutzbachenterprises.com. Bug reports and feature requests may be reported on our bug tracker at: http://github.com/DanielStutzbach/blist/issues

How we test

In addition to the tests include in the source distribution, we perform the following to additional rigor to our testing process:

  1. We use a “fuzzer”: a program that randomly generates list operations, performs them using both the BList and the built-in list, and compares the results.

  2. We use a modified Python interpreter where we have replaced the array-based built-in list with the BList. Then, we run all of the regular Python unit tests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blist-1.0.2.tar.gz (97.3 kB view details)

Uploaded Source

Built Distributions

blist-1.0.2.win32-py3.1.exe (249.0 kB view details)

Uploaded Source

blist-1.0.2.win32-py2.6.exe (252.1 kB view details)

Uploaded Source

File details

Details for the file blist-1.0.2.tar.gz.

File metadata

  • Download URL: blist-1.0.2.tar.gz
  • Upload date:
  • Size: 97.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for blist-1.0.2.tar.gz
Algorithm Hash digest
SHA256 23b24f3a7ecbdea282bcdbf13d6fdd74b5ed4742e5bb730ae3800000b77e6388
MD5 ef100f304891dc85f1159361f193f855
BLAKE2b-256 a7d8680568830f7b1635d5e049d2eed128e590d69d517028a3163c608582dea8

See more details on using hashes here.

File details

Details for the file blist-1.0.2.win32-py3.1.exe.

File metadata

File hashes

Hashes for blist-1.0.2.win32-py3.1.exe
Algorithm Hash digest
SHA256 d90a64a4dc11f860cc6ecc6422313eda5ffe3df6be96ff6c21ef5874810132ff
MD5 9ff214f73965ecaa3496cfa8b9552525
BLAKE2b-256 9131830445343c3f35260b521005bb5c1477752432ac20bbfcf22550dde3334b

See more details on using hashes here.

File details

Details for the file blist-1.0.2.win32-py2.6.exe.

File metadata

File hashes

Hashes for blist-1.0.2.win32-py2.6.exe
Algorithm Hash digest
SHA256 dab31dd17a98bac52acc66d2c8ac97123596d4e3c63807d550b48b281ff10d5f
MD5 387061e1913f58f045e2515f9a05ae37
BLAKE2b-256 7928278a64a8cbf41f966567b01694f27a4009a640ab4ae2534319ca53f3a972

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page