Skip to main content


Project description


Statically estimate asymptotic notation for a given Python function by looking at the level of loop-nesting inside the function.

this is an early prototype


from notations import notation

def my_example_function(arg1, arg2):
    f = 0
    for a in arg1:
        for i in a:
    for b in arg2:
        for j in b:


Will print Θ(n^2)

See for more examples.


This is a rough sketch of a concept at this stage.

  • while operators
  • Look at the relationship between input arguments in a function, just because a loop is nested, doesn't mean the O(n_n) is correct
  • branches inside loops
  • test comprehensions


  • Why not use the AST? The AST cannot be built at runtime (easily) from a code object, this library is intended to be used to evaluate the execution-order of a compiled function.
  • How could you possibly calculate the order without running the code? This function equates the order by looking at the level of loop-nesting in a function, the use of comprehensions and the relationships between arguments. Dynamic runtime benchmarks are susceptible to environmental conditions (noisy neighbours) and there are already plenty of tools out there that do this

Research notes



  • Change to theta values for repr


  • Initial prototype supporting basic for loops

Project details

Download files

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

Files for notations, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size notations-0.2.0.tar.gz (6.2 kB) File type Source Python version None Upload date Hashes View
Filename, size notations-0.2.0-py2.py3-none-any.whl (13.6 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page