Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pxeger/pycstats
Statistics on CPython bytecode
https://github.com/pxeger/pycstats
Last synced: 18 days ago
JSON representation
Statistics on CPython bytecode
- Host: GitHub
- URL: https://github.com/pxeger/pycstats
- Owner: pxeger
- License: agpl-3.0
- Created: 2021-08-19T19:58:13.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-07T20:07:05.000Z (about 3 years ago)
- Last Synced: 2024-10-12T09:31:48.365Z (about 1 month ago)
- Language: Python
- Size: 2.14 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pycstats
Statistics on Python bytecodeRequirements:
- CPython 3.9+
- pip
- [regex](https://pypi.org/project/regex/)
- bash
- curl
- jq
- unzip
- findTested on GNU/Linux and probably won't work anywhere else.
```bash
$ # download all packages and compile bytecode
$ ./download.sh
$ # analyse pyc files with regex-ish
$ # (e.g. look for LOAD_CONST followed by anything other than RETURN_VALUE)
$ find . -name '*.pyc' | ./analyse_regex.py LOAD_CONST '(?!' RETURN_VALUE ')'
...............
245
$ # scan all length-3 opcode sequences
$ find . -name '*.pyc' | ./analyse_sequences.py 3
208838 LOAD_CONST LOAD_CONST LOAD_CONST
165043 LOAD_CONST LOAD_CONST MAKE_FUNCTION
107435 STORE_NAME LOAD_CONST LOAD_CONST
103254 LOAD_CONST MAKE_FUNCTION STORE_NAME
81826 MAKE_FUNCTION STORE_NAME LOAD_CONST
[...]
```To use with the Python standard library:
```bash
$ sudo python -m compileall
$ find . /usr/lib/python3.9/ -name '*.pyc' | ./analyse_[...]
```