编程与软件工程github.com
Boltons:一组 BSD 许可的纯 Python 工具库
Boltons: A set of BSD-licensed, pure-Python utilities
2015 — 2018,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Boltons 是 Mahmoud Hashemi 维护的 BSD 许可纯 Python 工具库,把标准库之外常见的小工具集中起来,涵盖字典、迭代、文件、字符串、缓存、traceback 等模块;作者在评论中给出的数字是 79 个类型加 146 个函数。它不依赖第三方包,可以按需取用其中单个模块。
为什么经久不衰:它把许多人在项目里反复重写的样板工具整理成零依赖、易复制的实现,多年来一直是“标准库缺了什么”的实用参考答案。
HN 评论精选
作者亲自更新工具数量,并推荐自己最常用的几个模块。
我是库作者,也是懒得更新 README 的人:截至 2018 年 10 月 9 日,boltons 实际是 79 个类型加 146 个函数,共 225 个工具。顺便列出我最常用的几个:OrderedMultiDict,尤其是 .inverted() 和 .sorted();指数退避加抖动的生成器 backoff;remap(递归 map);atomic_save 原子写文件;traceback 工具(结构化 traceback)。另外还有我最喜欢、但不属于 boltons 的 glom。欢迎提交新工具,我很容易同意合并。
mhashemi查看英文原文
Library author and lazy README updater here to report that technically as of October 09, 2018, boltons is 79 types and 146 functions, for a grand total of 225 utilities. While I'm here, here are the ones I use most: - OrderedMultiDict: https://boltons.readthedocs.io/en/latest/dictutils.html#boltons.dictutils.OrderedMultiDict - esp the .inverted() and .sorted() methods - Exponential backoff and jitter generator: https://boltons.readthedocs.io/en/latest/iterutils.html#boltons.iterutils.backoff - remap (recursive map): https://boltons.readthedocs.io/en/latest/iterutils.html#nested (recipes here: https://sedimental.org/remap.html) - Atomic File saving: https://boltons.readthedocs.io/en/latest/fileutils.html#boltons.fileutils.atomic_save - Traceback utilties, structured tracebacks: https://boltons.readthedocs.io/en/latest/tbutils.html Also, my favorite bolton that's not a bolton, glom: https://glom.readthedocs.io/en/latest/ If you have a bolton you'd like to submit, I'm pretty merge-happy. Here are the criteria: https://boltons.readthedocs.io/en/latest/architecture.html
推荐功能相近的替代库 toolz/cytoolz。
Toolz 是我最喜欢的 Python 库之一,我一直在用,它提供更多这类实用功能,还有一个用 Cython 写的加速版 Cytoolz。
j88439h84查看英文原文
Toolz is one of my favorite python libraries. I use it all the time. It provides even more of this useful functionality. It also has a sped-up version called Cytoolz written with Cython. https://toolz.readthedocs.io https://github.com/pytoolz/cytoolz
建议用共享规范而非收入标准库来应对类似工具的碎片化。
我整体上很欣赏作者在 Python 方面的工作,虽然我本人不用 boltons。关于是否收进标准库的讨论很有道理,我完全同意作者的意见;可以对比 dataclasses 与 attrs 的类似讨论。不过,当你认为某个东西应该广泛可用,却不在标准库里时,确实有点烦。坏处是:碎片化,多个项目做类似的事;标准库自己也无法使用这个强大构件来简化代码。也许可以像 JS 社区的 Fantasyland 那样,先做一套共同规范,再让各项目自行实现,你觉得呢?
fermigier查看英文原文
I'm a big fan of @mhashemi's work in Python in general, even if I don't use Boltons personally. The discussion regarding inclusion in the stdlib is sensible, and I fully agree with @mhashemi's comments. See similar discussions, for instance, regarding dataclasses vs. attrs (https://github.com/ericvsmith/dataclasses/issues/19). Sometimes, however, it's a bit annoying when something that you think should be widely available isn't included in the stdlib. The cons of course are: - Fragmentation (several project pursuing similar objectives) - Not being able to use a powerful construct to simplify code in the stdlib itself (the stdlib can only depend on the stdlib). Regarding, for instance, functional programming, I maintain a list of interesting projects in this domain in Python: https://github.com/sfermigier/awesome-functional-python/blob/master/README.md#libraries There are at least half a dozen libraries that strive to achieve similar goals, and would probably benefit from being included in the stdlib (at least partially). It's hard to pick a winner among the list (like other in this thread, I went with toolz). I believe that a way to solve (at least partially) this conundrum could be to work on some common specifications, like the JS community did with Fantasyland (https://github.com/fantasyland/fantasy-land), and then let projects implements the specification the way they want. WDYT ?
2015 年时缺少 Python 3 支持是主要遗憾。
很喜欢这个思路,也很想在有些项目里用,但不支持 Python 3…… :'(
nuclear_eclipse查看英文原文
Really like the concept, and would love to use this in some of my projects, but no Python 3 support.... :'(
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选