一个小型的纯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 web应用程序组合到一个web应用程序(war)中而不相互影响?   java一次屏蔽两位   java如何在多个类上初始化元素?   java在后台服务中处理通知或使用GCM(或其他推送通知服务)   java从const方法调用JNI函数   javascript如何使用函数/方法返回?   Java优化:声明类变量与使用临时变量   java字符算术基数8 vs基数10   Java流收集要存储的对象列表   swing我正在用Java中的keyListener制作一个精灵移动器   在Gradle构建脚本中使用Scala(或java)方法   java Android Mediaplayer下一步按钮不起作用   Java Sound API在播放音频文件后将其锁定   java将变量从外部类传递到内部类的最佳方法   使用play framework的博客web应用程序出现java逻辑错误   java我们可以在Spring批处理中处理大型zip文件吗?   java如何检查JTable的选定行的特定列中的值是否已经在JList中?