Skip to main content

Notations

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

Example

from notations import notation

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

print(notation(my_example_function))

Will print Θ(n^2)

See test_notations.py for more examples.

TODO

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

FAQ

  • 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

Changes

0.2.0

  • Change to theta values for repr

0.1.0

  • Initial prototype supporting basic for loops

Metadata

Release files for notations 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notations 0.2.0
File Size Uploaded
notations-0.2.0.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for notations 0.2.0
File Interpreter ABI Platform
notations-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.8 kB

Release files / notations-0.2.0.tar.gz

Download URL notations-0.2.0.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
06177c0988ea986a3c7763692ff41b3262e0ba47528ad88898927a01efd1d522
BLAKE2b-256 checksum
How to use checksums
4dccf169ddf9b47f3b3b49c7ac2b33301de6d1484d74be701ab928814d8ccf93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.21.0

Release files / notations-0.2.0-py2.py3-none-any.whl

Download URL notations-0.2.0-py2.py3-none-any.whl
Size 13.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c8a77e6974cfad5e7112da3e474df2255048fdb930021070486bcbffd8a85386
BLAKE2b-256 checksum
How to use checksums
f08df9f88c72ff6e26225fa78068d5933555b49f969faa48857c9dc52aac9d55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.21.0

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page