Boltons

就像内置插件,但却是 boltons。250+ 构造、秘诀以及扩展 (并且不依赖于) Python 标准库的片段。和 Michael Bolton 完全不同。「🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.」

Github星跟蹤圖

Boltons

boltons 应该是内置的。

Boltons 是一套超过 230 个 BSD 授权的纯 Python 实用程序,其精神与标准库相同,但却包含标准库中明显缺失的部分,其中包括:

原子文件保存,与 fileutils 连接在一起。
一个高度优化的OrderedMultiDict,在 dictutils 中。
两种类型的优先级队列(PriorityQueue),在 queueutils
Chunked(分块式)windowed(窗口式)迭代,在 iterutils
递归数据结构 iteration and merging(迭代和合并),使用 iterutils.remap
通过 iterutils.backoff 实现包括抖动在内的指数反冲功能。
一个全功能的 TracebackInfo 类型,用于表示堆栈跟踪,在 tbutils 中。

完整而广泛的文档可在 "阅读文档" 上查阅。 通过检查 CHANGELOG查看新的内容。

Boltons 在 Python 2.6、2.7、3.4、3.5、3.6、3.7、3.8 和 3.9,以及 CPython nightly 和 PyPy/PyPy3 上进行了测试。

安装方法

Boltons 可以通过几种方式添加到一个项目中。有一个显而易见的方法,那就是:

pip install boltons

在 macOS 上,它也可以通过 MacPorts 安装:

sudo port install py-boltons

然后,多亏了 PyPI,几十个 boltons 只需导入即可:

from boltons.cacheutils import LRU
my_cache = LRU()

然而,由于实用程序的性质,应用程序开发人员可能需要考虑其他选项,包括将单个模块供应商化为一个项目。Boltons 是纯 Python 的,没有依赖关系。如果整个项目太大,每个模块都是独立的,可以直接复制到一个项目中。更多细节请参见文档中的集成部分。

第三方配套

大多数 boltons 努力做到 "足够好",以满足广泛的基本使用,而将高级用例留给 Python 无数专门的第三方库。在许多情况下,当用例超过 boltons 时,各自的 boltons 模块会描述值得研究的第三方替代方案。如果您发现了一个自然的 "next-step" 库值得一提,请看下一节。

差距

发现标准库中缺少一些应该在 boltons 中出现的东西?发现 boltons 中缺少了什么?首先,请花点时间阅读一下简短的 架构声明,以确保这些功能很适合。

然后,如果你很有动力,提交一个 a Pull Request。否则,在 Issues 页面 提交一个简短的功能请求,我们会想办法解决。


概覽

名稱與所有者mahmoud/boltons
主編程語言Python
編程語言Python (語言數: 1)
平台Linux, Mac, Windows
許可證Other
發布數49
最新版本名稱24.0.0 (發布於 2024-03-31 15:41:29)
第一版名稱0.3.0 (發布於 2014-10-19 14:32:03)
創建於2013-02-20 06:17:12
推送於2024-03-31 22:42:02
最后一次提交2024-03-31 15:41:50
星數6.4k
關注者數141
派生數346
提交數1.6k
已啟用問題?
問題數161
打開的問題數52
拉請求數153
打開的拉請求數17
關閉的拉請求數34
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?

Boltons

boltons should be builtins.





Boltons is a set of over 230 BSD-licensed, pure-Python utilities
in the same spirit as — and yet conspicuously missing from —
the standard library, including:

Full and extensive docs are available on Read The Docs. See
what's new by checking the CHANGELOG.

Boltons is tested against Python 2.6, 2.7, 3.4, 3.5, 3.6, and 3.7, as well as CPython
nightly and PyPy/PyPy3.

Installation

Boltons can be added to a project in a few ways. There's the obvious one:

pip install boltons

Then, thanks to PyPI, dozens of boltons are just an import away:

from boltons.cacheutils import LRU
my_cache = LRU()

However, due to the nature of utilities, application developers might
want to consider other options, including vendorization of individual
modules into a project. Boltons is pure-Python and has no
dependencies. If the whole project is too big, each module is
independent, and can be copied directly into a project. See the
Integration section of the docs for more details.

Third-party packages

The majority of boltons strive to be "good enough" for a wide range of
basic uses, leaving advanced use cases to Python's myriad specialized
3rd-party libraries
. In many cases the respective boltons module
will describe 3rd-party alternatives worth investigating when use
cases outgrow boltons. If you've found a natural "next-step"
library worth mentioning, see the next section!

Gaps

Found something missing in the standard library that should be in
boltons? Found something missing in boltons? First, take a
moment to read the very brief architecture statement to make
sure the functionality would be a good fit.

Then, if you are very motivated, submit a Pull Request. Otherwise,
submit a short feature request on the Issues page, and we will
figure something out.

去到頂部