Ultra-fast inspect functions for Python
Project description
uinspect
This is a small Python package that offers fast runtime inspection similar to that of inspect module in Python. To install, simply do
pip install uinspect
benchmark
The following benchmark is generated from running the scripts in benchmark/.
Task name |
uinspect method1 |
uinspect method2 |
inspect |
speedup |
Cost (us/op) |
---|---|---|---|---|---|
Source location |
uinspect.get_location() - 0.21s |
uinspect.Frame() - 0.48s |
16.43s |
79.7x |
0.21 us/op |
Locals |
uinspect.Frame().locals - 0.99s |
N/A |
0.82s |
0.82x |
0.99 us/op |
Locals diff |
uinspect.Frame(2).collect_vars() - 2.94s |
N/A |
1.20s |
0.41x |
2.94 us/op |
Frame walking |
uinspect.FrameWalker({}).get_location() - 1.45s |
N/A |
52.27s |
35.9x |
1.46 us/op |
It turns out that the uinspect does not speed up the local variable calculation. This is because we have to run an expensive Python C API call regardless of whether it’s uinspect or inspect. As a result, the overhead is caused by the fact that uinspect needs to convert Python object to C++ object.
The lesson is to use inspect module for any local variables related manipulation since it’s faster, but use uinspect to obtain source location.
install from source
git clone https://github.com/Kuree/uinspect.git cd uinspect git submodule update --init python setup.py install
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file uinspect-0.0.5-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 78.5 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77ae70abf435e354eb8412f5f0d03155b50366a9350e346a1fcc949647c959ce |
|
MD5 | e6d3ef470b6f65e0541d868a251dec72 |
|
BLAKE2b-256 | a3367f7b81a058e4fed3ce62632d2547408de8890a2c26a166a5519f30bda1e2 |
File details
Details for the file uinspect-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 120.4 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8da5f4b2c599194945f0218441f33585a42d8e563e2e2301c499597beb9dfb1b |
|
MD5 | b2bd30f56c4611433e6d0de6c4c606e7 |
|
BLAKE2b-256 | 4348e30288360a4c653d3608951ed9d9c16119c728fb56b10bc339d4acced5da |
File details
Details for the file uinspect-0.0.5-cp311-cp311-macosx_10_15_universal2.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp311-cp311-macosx_10_15_universal2.whl
- Upload date:
- Size: 131.0 kB
- Tags: CPython 3.11, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73a19cbdf3fef87c52935a750930337595669e018778031d8779c16c1a9c0bad |
|
MD5 | 0eecb7ceb1bc0c5378e021c53bdc84e6 |
|
BLAKE2b-256 | 4d7fb258b8e499330f1a186d71a0deaf8795208a18bbdb2249f49e52da3042dd |
File details
Details for the file uinspect-0.0.5-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 78.5 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6382ba5091612f15983961d3abd7ea25bb0b170f76dd2dcee0b6a5009a7309f6 |
|
MD5 | 9438d6ae805fc143384db23e583589c5 |
|
BLAKE2b-256 | 10115c1d5419cd23805e3873b607e575f0983d6bc1784d4cf8e818244683eb69 |
File details
Details for the file uinspect-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 120.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ecd7ed1c4f56d296ba932d16d1484dae77659c6d0f3cfb4c042ce7b7ee9727e |
|
MD5 | 9f4ea66064e39c8f6a677cf939b23bc3 |
|
BLAKE2b-256 | 753c309272707123d1d0c064eb8085c9f9163546a26bf83417958dca12d29fa9 |
File details
Details for the file uinspect-0.0.5-cp310-cp310-macosx_10_15_universal2.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp310-cp310-macosx_10_15_universal2.whl
- Upload date:
- Size: 130.9 kB
- Tags: CPython 3.10, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e5444a5d988cb964cfb408312cb535566221c8411ddea940f810bf514dcb69b |
|
MD5 | d80958b37146d29f94c96464e419bb7a |
|
BLAKE2b-256 | aab767adb863a9ec4d7fc0baf37bb6dd7e6d03d131ed6dcb7b3504fba3081e6b |
File details
Details for the file uinspect-0.0.5-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 78.6 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2f961d636de35c1dbeef77528a15cff6fb37fd8271fafead7337f7b22691e4f |
|
MD5 | a18a04ff13fcbeb1e1d960ec26e80ee1 |
|
BLAKE2b-256 | 3c5b205bbd0c7020dc111c61cca57cc518c1c8590714a2d79d239b32b2ed486f |
File details
Details for the file uinspect-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 120.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b1ef4a251de5ec43e313f64c8eab9fbbd958342d6118b63b98a6dadc9c0964d |
|
MD5 | 61fb66fe156e8e88fbf91c0d5804c523 |
|
BLAKE2b-256 | b1038ed5f49df1398298302b59cc9be3834c570b2f812f2d01ac9fde238b7799 |
File details
Details for the file uinspect-0.0.5-cp39-cp39-macosx_10_15_universal2.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp39-cp39-macosx_10_15_universal2.whl
- Upload date:
- Size: 131.2 kB
- Tags: CPython 3.9, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13f4b55a61f2338a96360f9b1a23df97fb49dd418750e6dac009322508d43f02 |
|
MD5 | 54377285f83d598e89c96e3dc9d2d940 |
|
BLAKE2b-256 | c33dead7861c7c81bd454445d2637acac58d12d61a75d6570e87bce91149527b |
File details
Details for the file uinspect-0.0.5-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 78.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 558abfb2c3ab2e566118be1331dc6ad23dc551f6410c8e6591fdd61530ccef7f |
|
MD5 | 541478282cf1f8c4965c2922f0da4ca1 |
|
BLAKE2b-256 | 26851ea30b7c9c22034b9400aeaef0d8f4dc573dfe8679cd1de64359e0514963 |
File details
Details for the file uinspect-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 120.3 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 748b6630c60ad10c2962ad7652245481c155923d083853d0d1861b1405ff1e1c |
|
MD5 | 375e4744df09abeeb37c3e4d3d0b03a1 |
|
BLAKE2b-256 | 7ebd18f138e19c684af4d738b90211ef6bd602803a011a9679c34abd4a566bc5 |
File details
Details for the file uinspect-0.0.5-cp38-cp38-macosx_10_15_universal2.whl
.
File metadata
- Download URL: uinspect-0.0.5-cp38-cp38-macosx_10_15_universal2.whl
- Upload date:
- Size: 130.8 kB
- Tags: CPython 3.8, macOS 10.15+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d791eaea3894eebf60859a82bdb619a1ddd54b4e44cc81ea8a52599daadee6 |
|
MD5 | a686820866efbda01ef47c0e12515575 |
|
BLAKE2b-256 | ef684950bb855a6362a4914c449aef95ce355619cb163face0d1f67ed29c7b34 |