Skip to main content

Supported Versions

常用装饰器工具集

pip安装

pip install detool

1.统计函数执行时长装饰器

import time
from detool import timer_cost

@timer_cost
def t_time():
    time.sleep(0.01)
    print(123)

2.redis缓存装饰器

    from detool import RedisCache

    redis_cache = RedisCache(host='127.0.0.1', password='', port=6379, db=0)

    @redis_cache.cache(ttl=30)
    def sum_t(a, b):
        print(f'{a}+{b}={a + b}')
        return a + b

    r = sum_t(1, 2)
    print(r)

3.日志装饰器

    from detool import class_log_decorator,log_decorator

    @class_log_decorator
    class Cal(object):
        def __init__(self, c):
            self.c = c

        def sum(self, a, b):
            return a + b
    @log_decorator
    def calculate(a, b):
        return a + b

    Cal(3).sum(a=3, b=6)

4.异常捕获装饰器

    from detool import class_exception_decorator,exception_decorator

    @exception_decorator
    def r_exception():
        raise Exception("function Exception raised")


    @class_exception_decorator
    class ClassException(object):
        def r_exception(self):
            raise Exception("class Exception raised")


    r_exception()
    ClassException().r_exception()

5.分析内存装饰器

    from detool import profile

    @profile
    def t_memory():
        return [i for i in range(1, 1001)]

    t_memory()

Metadata

Release files for detool 1.1.3

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

Source distribution (sdist)

Source distribution for detool 1.1.3
File Size Uploaded Provenance Actions
detool-1.1.3.tar.gz 4.0 kB Without provenance Details for detool-1.1.3.tar.gz

Built distribution (wheel)

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

Total release size: 11.8 kB

Release files / detool-1.1.3.tar.gz

Download URL detool-1.1.3.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8702aa10982ef2c3465d4b5f26e552c7bc4f9e4fb1cff4ec5caf90bbd3b358c9
BLAKE2b-256 checksum
How to use checksums
15ce47b230634ee3dc66f8de875ed155b0ff40d7e51c2ff24eebf3ba14662cf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.4.2 requests/2.24.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.1

Release files / detool-1.1.3-py3-none-any.whl

Download URL detool-1.1.3-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93c0e28ed549e82adc03891fed7a58b2a48500b442c47f9071439747ad58a87d
BLAKE2b-256 checksum
How to use checksums
89c604342b09fea0c62214046a556403eeaf679a73889fcb755e68599739972b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.4.2 requests/2.24.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.1

Security for detool 1.1.3

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.

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