Skip to main content

这是一个基于python的高拓展性计算器

Project description

hpyculatorPackage

PyPI - License PyPI - Python Version Codacy Badge codecov PyPI - Downloads GitHub repo size

基于python3.10

https://github.com/HowieHz/hpyculator

这个仓库是hpyculator的附属模块,如开发hpyculator插件需要此模块

安装方法

pip install hpyculator

子模块

hpycore

常量:
STRING = 1 << 0
NUM = 1 << 1
FLOAT = 1 << 2
LIST = 1 << 3

ON = 1 << 1
OFF = 1 << 0

RETURN_ONCE = 1 << 0
RETURN_ITERABLE = 1 << 1
RETURN_ITERABLE_OUTPUT_IN_ONE_LINE = 1 << 2
NO_RETURN = 1 << 3
NO_RETURN_SINGLE_FUNCTION = 1 << 4

函数
def write(anything, end="\n") -> None:
"""
用于向指定的文件流写入,每次写入之后立即刷新缓存区(立即写入硬盘)

:param anything: 要写入的东西
:param end: 每次写入在末尾追加的东西,默认为换行符
:return: None
"""

def write_without_flush(anything, end="\n") -> None:
"""
用于向指定的文件流写入,每次写入之后不刷新缓存区,需要手动刷新(使用flush函数)

:param anything: 要写入的东西
:param end: 每次写入在末尾追加的东西,默认为换行符
:return: None
"""

def flush() -> None:
"""
用于刷新缓存区(将缓存区中的数据写入硬盘)

:return: None
"""

def output(anything) -> None:
"""
输出到框体

:param anything: 要输出到框体的数据
:return: None
"""

细节请看文档https://hpyculator.readthedocs.io/

hpydecorator

实用装饰器
    reRunTimes: 计量函数运行时间,并可以指定运行次数,如要运行5次 @reRunTimes(5),返回值变为(原返回值,运行时间(单位ns))
    def reRunTimes(times: int = 1) -> Callable:
    """
    一个装饰器,用来计算函数运行时长,这个函数是装饰器参数
    
    ---------------------------------------------
    
    返回一个元组:(原函数调用结果,ns为单位的运行时长)
    
    :param times: 运行次数,默认为1
    :return Tuple: 原函数调用结果,ns为单位的运行时长
    """       

    funName: 给原函数传入关键字参数__fun_name__,用于获取原函数名
    funName(fun: Callable) -> Callable:
    """
    一个装饰器,函数形参增加__fun_name__用于获得函数名

    ---------------------------------------------

    使用方法:

    原函数
        def a(c, b: int = 1):

    ->

    改成
        def a(c, b: int = 1, __fun_name__):

    :param fun: 一个函数
    :return: 一个函数
    """

hpysettings

用于快捷管理json,yaml,toml设置文件
load函数用于创建一个设置文件对象(返回一个创建好的设置文件对象)
设置文件对象的add,delete,modify方法支持链式调用

hpyfunc

def flatten(sequence: Union[list, tuple]) -> list:
"""
将多维数据结构展平为一纬数据结构

:param sequence:
:return: list
"""

def flatten_layer(sequence: Union[list, tuple]) -> list:
"""
将多维数据结构展平一层

:param sequence:
:return: list
"""

def flatten_no_recursion(sequence: Union[list, tuple]) -> list:
"""
将多维数据结构展平为一纬数据结构(无递归) 效率低很多

:param sequence:
:return: list
"""

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hpyculator-1.5.0.tar.gz (22.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page