跳转至

581-590

Issue #581 Zen of Python, JupyterLab 4.0, Zelda Puzzle, and More June 13, 2023

又一个GIL的PEP,先看一眼状态果然还是Draft

Cite

The Right Way to Run Shell Commands From Python
These are all the options you have in Python for running other processes - the bad; the good; and most importantly, the right way to do it MARTIN HEINZ • Shared by Martin Heinz

推荐了一手https://pypi.org/project/sh/这个库

Cite

Flask Authentication Guide
This guide will help you learn how to secure a Flask web application using token-based authentication. AUTH0 DEVELOPERS • Shared by Robertino

Authlib,看起来各种主流认证方式都有,还有OAuth2的实现,跟各种Python Web框架都有集成,值得一看。

Issue #582 Faster Python Plan, Community, Hating AsyncIO, and More June 20, 2023

Cite

Faster Python 3.13 Plan
This brief outline highlights the plan for the faster CPython project for the 3.13 release. Includes PEP 669, PEP 554, improved memory management, and more. Associated Hacker News discussion. GITHUB.COM/FASTER-CPYTHON

一些关于CPython提速的工作,主要在这个仓库

Issue #583 Search DSLs, CircuitPython, Debugging Kubernetes, and More June 27, 2023

Cite

Python 3.12.0 Beta 3 Released
CPYTHON DEV BLOG

看到了这个关于f-string的pep,比以前限制更少,更好用了

Cite

Designing Pythonic Library APIs
This article summarizes principles that Ben has found useful when designing Python library APIs. Topics include: structure, naming, error handling, and type annotations. BEN HOYT

一些设计的准则,也涵盖了很多Pythonic的技巧,很不错的文章

Issue #584 Fast range(), Alternate Interpreters, PSF Security Dev, and More July 4, 2023

Cite

Counting Occurrences in Python With collections.Counter
Python’s collections.Counter objects are helpful for counting occurrences of iterable items. They’re especially helpful when paired with generator expressions. TREY HUNNER • Shared by Trey Hunner

from collections import Counter

Issue #585 Python 3.12 Profiler, Netflix, Numba Vectorize, and More July 11, 2023

Cite

Python 3.12 Preview: Support for the Linux Perf Profiler
Python 3.12 will be released in October 2023. In this tutorial, you’ll preview one of its upcoming features: support for the Linux perf profiler, which will give you a holistic view of your application’s performance, including system-level and hardware-level events. REAL PYTHON

perf支持

Cite

creosote: Identify Unused Dependencies
GITHUB.COM/FREDRIKAVERPIL

不支持importlib,有点不敢用,mark一下

Issue #586 Mazes, Organizing Monoliths, Passing NumPy Arrays, and More July 18, 2023

自由讨论

项目介绍里说是Flask的异步实现,Flask在较新的版本上也支持了异步,不过一直没怎么用过

Issue #587 Folium, 6502 Emulator, Pystack, and More July 25, 2023

看标题的第一眼觉得还挺好,虽然大部分的时候写个单文件的小脚本不怎么在意依赖的问题,都是缺哪个包就装哪个,但是没有依赖描述文件确实也是个痛点。看了一下社区的讨论,基本都是批评的声音,读了一下感觉社区说的对...

Issue #588 F-Strings in Py3.12, Profiling, Quirks, No-GIL, and More Aug. 1, 2023

Cite

Python 3.12 Preview: More Intuitive and Consistent F-Strings
In this tutorial, you’ll preview one of the upcoming features of Python 3.12, which introduces a new f-string syntax formalization and implementation. The new implementation lifts some restrictions and limitations that affect f-string literals in Python versions lower than 3.12. REAL PYTHON

f-string的一些优化,可以在里面使用反斜杠了,也支持任意级别的嵌套,f-string里面甚至还能写行内注释了

Issue #589 Pandas 2.0, Foreign Functions, Versioning, and More Aug. 8, 2023

Cite

Pydantic v2.1 Released
PYDANTIC.DEV

FastAPI用的这个库,没用过已经更新到V2版本了,简单看了一下example,感觉和dataclass+dataclass-json用起来差不多

Cite

“Why Python Is Terrible”
HACKER NEWS

1

Issue #590 Annotating self, Context Managers, PEP 723, and More Aug. 15, 2023

Cite

How to Annotate Methods That Return self
In this tutorial, you’ll learn how to use the Self type hint in Python to annotate methods that return an instance of their own class. You’ll gain hands-on experience with type hints and annotations of methods that return an instance of their class, making your code more readable and maintainable. REAL PYTHON

3.11以上from typeing import Self,以下from typeing_extensions import Self

Cite

PEP 723: Embedding pyproject.toml in Single-File Scripts
This PEP proposes a metadata format which a single-file script can use to specify dependency and tool information for IDEs and external development tools. It replaces PEP 722. PYTHON.ORG

感觉挺合理的啊,在脚本内,就是不知道这种有意义的注释的写法能不能被接受

__pyproject__ = """
[project]
requires-python = ">=3.11"
dependencies = [
  "requests<3",
  "rich",
]
"""

import requests
from rich.pretty import pprint

resp = requests.get("https://peps.python.org/api/peps.json")
data = resp.json()
pprint([(k, v["title"]) for k, v in data.items()][:10])

评论