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 |
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.
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
Hashes for uinspect-0.0.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b037e08e6ad44d15b2143c5786d4e76407800ff58c0507d08b335fb0a2c7b06 |
|
MD5 | 3bb00bdbd1582a85714f7316e893dbe7 |
|
BLAKE2b-256 | 286e5c85330f71e5658e1726f0751a0da0de955e1931f46b314f8148fc3c8a1c |
Hashes for uinspect-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4c2f02d3a0eb1989c0c1af80d62c57892e4871342824ee1cbb65d8a190592e0 |
|
MD5 | 33ded07f56314c737f2ebcc68b8b54eb |
|
BLAKE2b-256 | 9896579f70f402bf32c9ad51287217d577debb97edab8fb4a925235cb2b06554 |
Hashes for uinspect-0.0.2-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e17fd56c04c8c1bba4d45b8e3a00752951105b7ae19fa896484b525984929f01 |
|
MD5 | 4619740b37c8661531f199332974f850 |
|
BLAKE2b-256 | 8d77eb23175409f3aa47620da78ad870ab2925f0287fab6ab0c1df26dcb5d62d |
Hashes for uinspect-0.0.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d15472f511774471ce3f66b0e9b99881138e2cd20e02ade8d4363d47ce6f735 |
|
MD5 | 6f1da87e24f2a895136d1700829e3ac5 |
|
BLAKE2b-256 | 156d55b445620f87f74a7a24b49e486b8c866824a63bf5d1b304612767f2ae16 |
Hashes for uinspect-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7abf511330854674f0404602139afbfb33de467413017ade8920540ab4f1046e |
|
MD5 | 60fc9f79d1bfabeb0c0cf569c7ebe398 |
|
BLAKE2b-256 | b82654caf33278bca0ea067d268af0f1596dd238ad38ef1ff4cb3ca406b59fec |
Hashes for uinspect-0.0.2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4c524eb26de6954127d17bf0f7fee43de5c4f83ef59d10435be3389ec7f64fd |
|
MD5 | d3e18f22347f157ccd411a6d059954e7 |
|
BLAKE2b-256 | d057d1e3b9a0915be43ca3ecab7c2dcfcaf92977b4862b95209128a0fae3b8c6 |
Hashes for uinspect-0.0.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38e6b3bd51da872982097425ed366a45c8f5e0734525ffbac3b7444e8a24f772 |
|
MD5 | aee18bd4a17f8703ca281895a279328f |
|
BLAKE2b-256 | 15b192e0bbb7bfbbd5051f881abbae681c9ef8619ae2a646d59149605df497bc |
Hashes for uinspect-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0959b001b4bc00c2fab990b7bcbdccf312be79f39c148bd96d0d3ab1686df44f |
|
MD5 | 8539558084e40440fcde3e24b8d738f4 |
|
BLAKE2b-256 | dc1c689f03391771e47be701429f746e935482da426971743d9df6033371b2b9 |
Hashes for uinspect-0.0.2-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29eeff8c479e6da433dbb362f46de911e8e6e6b1c919db6536a9b31c30189950 |
|
MD5 | 0ac40e947bfcd64be8200f4fdf49c9c9 |
|
BLAKE2b-256 | b987a309d9a383ae0c7be7058e95d8fa0b73a231c5263a512c057c615ceedb9b |
Hashes for uinspect-0.0.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d36c2ccfbcbcbbeb1566863f44dc12e36b055ea13f236bed4970019ae13072a |
|
MD5 | fc102c94287281e6b5236464de86d8a4 |
|
BLAKE2b-256 | 1b4f6d59ed12a19dc24aaa6c2dc2618bc1d01763cf4a6705150cd98b05f30d9a |
Hashes for uinspect-0.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d56fd20569ef0204bf1bcb7261d850266c5cbdfb0d30325afc0b49e527feaa2 |
|
MD5 | 6884450e9385af5617bd15c542c78eb4 |
|
BLAKE2b-256 | bcd0fca185ffa219813103a8f219aa2ab6cf2a9dfbe8aa7faacee362005abc36 |
Hashes for uinspect-0.0.2-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7feb39d464435bc1a63f1215ec17bf00caeda9c22da6a62d5a846902839c83d |
|
MD5 | 25e8fb9fa549b3b20ab5fa6b35142ac4 |
|
BLAKE2b-256 | 41571efbfd959f888982df7da1a276254cb280f244767eed32102dd6bc033816 |