Skip to main content

pymwp is a tool for automatically performing static analysis on programs written in C. It analyzes resource usage and determines if a program's variables growth rates are no more than polynomially related to their inputs sizes.

For example,

int main(int X1, int X2, int X3){
    X1 = X2 + X3;
    X1 = X1 + X1;
}

is satisfactory because—between the initial variable values (Xi) and the final values (Xi')—all variables have a polynomially bounded data-flow (omitting constants): X1' ≤ X2+X3 and X2' ≤ X2 and X3' ≤ X3. pymwp derives this bound automatically (⯈ demo).

However, program

int main(int X1, int X2, int X3){
   X1 = 1;
   while (X2 > 0){ X1 = X1 + X1; }
}   

fails the analysis, because X1 grows exponentially (X1' = $2^{\texttt{X2}}$). pymwp reports a program is infinite when no polynomial bound can be derived (⯈ demo).

pymwp is inspired by "A Flow Calculus of mwp-Bounds for Complexity Analysis". Try our online demo to see it action. For more details, see pymwp documentation, particularly supported C language features.

Documentation and Demo

The user guide is the ideal place to start for a general and interactive introduction to pymwp.

Installation

Install the latest release from PyPI

pip install pymwp

How to Use

Command-Line Use

To analyze a C file, run in terminal:

pymwp path/to_some_file.c

For a list of available command options and help, run:

pymwp

Use in Python Scripts

You can also use pymwp by importing it in a Python script. See modules documentation for details and examples.

Running from source

If you want to use the latest stable version—possibly ahead of the latest release, and with special evaluation utilities and input examples—use pymwp directly from source.

  1. Clone the repository

    git clone https://github.com/statycc/pymwp.git 
    cd pymwp
    
  2. Set up Python runtime environment of preference

    🅰️   Using Python venv↗

    Create and activate a virtual environment (POSIX bash/zsh):

    python3 -m venv venv
    source venv/bin/activate
    

    Install required packages:

    python -m pip install -r requirements.txt
    

    For development, install dev-dependencies instead:

    python -m pip install -r requirements-dev.txt
    

    🅱️   Using Docker↗

    Build a container -- also installs dev-dependencies:

    docker build . -t pymwp
    

    Run the container:

    docker run --rm -v "$(pwd):$(pwd)" pymwp
    
  3. Run the analysis

    From project root run:

    python -m pymwp path/to_some_file.c
    

    for example:

    python -m pymwp c_files/basics/if.c
    

    for all available options and help, run:

    python -m pymwp
    

Metadata

Release files for pymwp 0.5.5

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

Source distribution (sdist)

Source distribution for pymwp 0.5.5
File Size Uploaded
pymwp-0.5.5.tar.gz 67.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymwp 0.5.5
File Interpreter ABI Platform
pymwp-0.5.5-py3-none-any.whl Python 3 none any Details

Total release size: 145.5 kB

Release files / pymwp-0.5.5.tar.gz

Download URL pymwp-0.5.5.tar.gz
Size 67.1 kB
Tags Source
SHA-256 checksum
How to use checksums
794ce0a747fbfd1295eba3dbc6095888c0c54193725393aafa956e9f69cfc0f9
BLAKE2b-256 checksum
How to use checksums
2916b8ee988db4471f2066a75a5efabb3a28070625a8c688d35287e8ffa85662
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release files / pymwp-0.5.5-py3-none-any.whl

Download URL pymwp-0.5.5-py3-none-any.whl
Size 78.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abde666a15b2707aa17a894d36415a6e7136b3bbb96990b0f6bf872f49b3dc9f
BLAKE2b-256 checksum
How to use checksums
b72e0f3fc706c9472dd41ffeb91b778622c1870e66d25912f24354b68a3b7ebc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.5.5 This release

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

1 release file

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