Symbolic representation of big-O notation
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bigO
test
.gitignore
.travis.yml
LICENSE
README.md
setup.cfg
setup.py

README.md

bigO

PyPI version Build Status

Symbolic representation of big-O notation.

I was looking for something like this but couldn't find it. So I wrote it, and it turned out to be much simpler than I expected.

Note that much of this functionality can now be achieved using sympy.series.order, if you're careful to specify that your limits go to infinity.

Usage

import sympy
from bigO import O, n

f_time = O(n)
g_time = O(n**2)
h_time = O(sympy.sqrt(n))

fastest_asymptotically = min(f_time, g_time, h_time)
# = h_time

total_time = f_time.inside(g_time).followed_by(h_time)
# = O(n**3)

# If you prefer a less verbose API:
total_time = f_time * g_time + h_time
# = O(n**3)