Torbjorn
🔨 提供一些实用的 Python 装饰器~
Torbjorn(即托比昂)是守望先锋游戏中的英雄之一,他拥有一个强力输出的炮台。
俗话说「他强任他强,我用托比昂」,我希望本项目也能给你的 Python 代码提供强力的支持!
🎈️ v0.1.1:
使用
time.perf_counter计算时间,以提高精准度。
安装
# pip 安装
pip install torbjorn
# or 源码安装
git clone https://github.com/Ailln/torbjorn.git
cd torbjorn && python setup.py install
使用
run_time: 计算运行时间run_count: 计算运行次数ctrl_c: 程序终止验证
import logging
import torbjorn as tbn
logger = logging.getLogger(__name__)
@tbn.run_time
@tbn.run_time(name="test_time")
@tbn.run_time(logger=logger, name="test_time")
@tbn.run_count
@tbn.run_count(name="test_count")
@tbn.run_count(logger=logger, name="test_count")
@tbn.ctrl_c
def calculate_million_numbers(num):
number = 0
for _ in range(num):
number += 1
if __name__ == '__main__':
for _ in range(10):
calculate_million_numbers(1000000)
# output:
# [calculate_million_numbers] run count(t): 1
# [test_count] run count(t): 1
# [test_count] run count(t): 1
# [test_time] run time(s): 0.074010
# [test_time] run time(s): 0.074463
# [calculate_million_numbers] run time(s): 0.074512
# [calculate_million_numbers] run count(t): 2
# [test_count] run count(t): 2
# [test_count] run count(t): 2
# [test_time] run time(s): 0.074386
# [test_time] run time(s): 0.074522
# [calculate_million_numbers] run time(s): 0.074556
# ^CAre you sure to quit? (yes|y) / (no|n)
# >> 123
# ^CAre you sure to quit? (yes|y) / (no|n)
# >> no
# [calculate_million_numbers] run count(t): 3
# [test_count] run count(t): 3
# [test_count] run count(t): 3
# [test_time] run time(s): 0.072722
# [test_time] run time(s): 0.072863
# [calculate_million_numbers] run time(s): 0.072897
# ^CAre you sure to quit? (yes|y) / (no|n)
# >> yes
# >> exit...
许可
Metadata
Release files for torbjorn 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torbjorn-0.1.1.tar.gz | 4.4 kB | Without provenance | Details for torbjorn-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torbjorn-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for torbjorn-0.1.1-py3-none-any.whl |
Total release size: 9.9 kB
Release files / torbjorn-0.1.1.tar.gz
| Download URL | torbjorn-0.1.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bcf36a970215d8df8b6d7eeaa2259c627ada3a194967f07804409f3867008b7
|
|
BLAKE2b-256 checksum How to use checksums |
834f42cbdcc7ebb5bb0aaaeb68a3a26cdf2a89a7faf32d595baf8589164c4223
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.8
|
Release files / torbjorn-0.1.1-py3-none-any.whl
| Download URL | torbjorn-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17f9f1efc730207d82c63d04637bd960dc0645bd8fbcdfded59896f693b23c77
|
|
BLAKE2b-256 checksum How to use checksums |
0e62d83ae551a8c213d5f4cc991267444315e84ae519838e6799a075c75b727f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.4 tqdm/4.59.0 importlib-metadata/3.10.0 keyring/22.3.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.8.8
|
Security for torbjorn 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.