一个小型的纯python实用程序包。

decore的Python项目详细描述


PyPI-StatusPyPI-VersionsBuild-StatusCodecovLICENCE

一个小型的纯python实用程序包。

fromdecoreimportlazy_property@lazy_propertydefparamless_big_calc():sub_res=[big_func(const)forconstinarray_of_constants]returnsum(sub_res)

1   Installation

使用以下命令安装decore

pip install decore

2   Decorators

2.1   lazy_property

lazy_propertydecorator用于修饰计算某些常量值或属性的函数,这些常量值或属性只需要计算一次。对修饰函数的第一次调用将运行它并在返回之前保存该值(在内存中);随后的调用将在不触发计算的情况下获取该值。

对于没有参数的函数,可以将其看作functools.lru_cache(maxsize=1)

fromdecoreimportlazy_property@lazy_propertydefparamless_big_calc():"""I take a lot of time!"""sub_res=[big_func(const)forconstinarray_of_constants]returnsum(sub_res)

2.2   threadsafe_generator

threadsafe_generatordecorator使生成器具有线程安全性。这意味着可以为多个线程提供对修饰生成器的引用,并且保证流中的每个项都将只生成(即返回)一个线程。

fromdecoreimportthreadsafe_generator@threadsafe_generatordefuser_documents(day):"""I yield some MongoDB documents!"""client=get_mongodb_client(some_params)dt_obj=translate_day_to_dt(day)user_document_cursor=client.some_mongodb_query(dt_obj,SOME_CONST)whileTrue:yielduser_document_cursor.__next__()

3   Contributing

软件包作者和当前维护者是shay palachy(shay.palachy@gmail.com);非常欢迎您向他寻求帮助。捐款是非常受欢迎的。

3.1   Installing for development

克隆:

git clone git@github.com:shaypal5/decore.git

以开发模式安装,测试依赖项:

cd pdpipe
pip install -e ".[test]"

3.2   Running the tests

要运行测试,请使用:

python -m pytest --cov=decore

3.3   Adding documentation

这个项目是使用numpy docstring conventions来记录的,之所以选择它们,是因为它们可能是最广泛传播的约定,它们都得到了sphinx等常用工具的支持,并产生了人类可读的docstring(当然,在我个人看来)。在记录添加到此项目中的代码时,请遵循these conventions

4   Credits

由shay palachy(shay.palachy@gmail.com)创建。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Android Studio:我的短信应用程序不是默认短信应用程序的选项之一   java处理字符串问题   java为什么我的程序打印“null”而不是字符串?   java为什么要创建一个无限循环?   java循环在一段时间后将布尔值更改为false?   java Android Rest Api Post 400错误请求   java调用另一个方法以获取resultset并正确关闭连接?   java我想在2d数组中添加一行   Java:我需要从outputstream中获取字节数组   C语言中Java元注释的等价物#   java如何在从web下载图像时保持原始图像的dpi?   java中基于输入值的spring boot动态值   java从请求中获取主机名   java可以复制Swing代码并在intelliJ中的designer中查看它吗   spring如何使用java配置多个ldap   安卓如何在Java中使用具有多个类似参数的JSON请求/响应循环?   java LIbGDX如何在语言更改时翻译所有文本?