491-500¶
Issue #491 Structural Pattern Matching, Generator Expressions, Python Steps Forward, and More Sept. 21, 2021¶
Structural Pattern Matching in Python 3.10
“Python 3.10, which is due out in early October 2021, will include a large new language feature called structural pattern matching. This article is a critical but (hopefully) informative presentation of the feature, with examples based on real-world code.”
BEN HOYT
作者好像对这个特性不是特别满意,不过我觉得这个功能还是比较优秀的,无论如何是更有利于用户使用。虽然switch各个语言都有, 不过Python还是实现的最优雅的那个
Django 4.0 to Get a Built-in Redis Cache Backend
GITHUB.COM/DJANGO
Django还是有点东西的,flask就感觉更新很慢
quit(), exit(), sys.exit(), os._exit(): The Differences and Do They Matter?
解释在这里
大多数情况下就用sys.exit()
就行,不过我还是用exit()
,因为字比较少😂
Programming Languages: Python Is on the Verge of Another Big Step Forward
Python could soon take first place in one more programming language popularity ranking: “Python has never been so close to the number 1 position of the TIOBE index,” writes Paul Jansen, chief of Tiobe software. “It only needs to bridge 0.16% to surpass C. This might happen any time now. If Python becomes number 1, a new milestone has been reached in the TIOBE index. Only 2 other languages have ever been leading the pack so far, i.e. C and Java.”
LIAM TUNG
阅
Issue #492 Python GIL Deep-Dive, Django 4.0 is Coming, Python as a Build Tool, and More Sept. 28, 2021¶
Python Behind the Scenes: The GIL and Its Effects on Python Multithreading
GIL stands for the Global Interpreter Lock, and its job is to make the CPython interpreter thread-safe. This post tells you more about non-obvious effects of the GIL. Along the way, you’ll see what the GIL really is, why it exists, how it works, and how it’s going to affect Python concurrency in the future.
VICTOR SKVORTSOV
又出了一期,该找时间好好看看了
New Testing Features in Django 4.0
Django 4.0 had its first alpha release last week and the final release should be out in December. It contains an abundance of new features, which you can check out in the release notes. This post looks at the changes to testing in a bit more depth.
ADAM JOHNSON
基本都是test相关的一些更新
Stack Overflow: Python Just Surpassed Java as the 2nd Language With the Highest Number of Questions
黑我matplotlib?
What Is Pathlib?
The pathlib module was introduced in Python 3.4 and makes working with filesystem paths easier by implementing a Pythonic, OS-agnostic way to manipulate and interact with paths. In this quick video, Nafiul, developer advocate for PyCharm, hows how to use the library and some of its popular APIs.
JETBRAINSSPONSOR VIDEO
JetBrains倾情奉献 https://www.youtube.com/channel/UCak6beUTLlVmf0E4AmnQkmw
不需要新建修虚拟环境了,用法看起来有点像poetry和npm。项目都1K star了。不过pep 582还没接受呢,都已经实现了
Issue #493 All Things Python 3.10, Proportional Fonts, Python Editors, and More Oct. 5, 2021¶
Python 3.10: Cool New Features for You to Try
Explore some of the coolest and most useful features in Python 3.10. You’ll appreciate more user-friendly error messages, learn about how you can handle complicated data structures with structural pattern matching, and explore new enhancements to Python’s type system.
REAL PYTHON
这个报错的时候给我指出来异常发生的具体位置可是太香了,都3.10了才有这个。match也非常香
What Defines a Number in Python? The Question May Be Harder Than You Think…
Static type-checkers such as Mypy have grown increasingly popular in recent years in the Python community, yet it’s surprisingly difficult to write a type hint that will accept any number. This answer on Stack Overflow digs into why.
STACK OVERFLOW • Shared by Alex Waygood
之前碰到过这个问题,比如一个函数的参数是一个枚举类本身,而不是枚举类的实例,可以使用typing.Type
class E(Enum):
pass
def f(arg: Type(E)):
pass
Make Your Python App Interactive With a Text User Interface
Have you wanted to create a Python application that goes further than a command-line interface? You would like it to have a friendly interface but don’t want to make a GUI (Graphical User Interface) or web application. Maybe a TUI (Text User Interface)would be a perfect fit for the project. This week on the show, it’s Will McGugan talking about his projects Textual and Rich.
REAL PYTHON PODCAST
除了GUI还有TUI,比GUI省事,用文本来交互。都29K star 了,我觉得挺好 不过还是感觉最大的问题是有点走错路了,简答的场景用不到,复杂的场景做不来。还是GUI香,不过这个TUI界面已经做的基本天花板了,如果有适用的场景还是可以尝试一下的
Code Style Matters
An article about the importance of having a consistent Python coding style and tools that can help you achieve this goal.
RODRIGO GIRÃO SERRÃO
简单的介绍,介绍了一些代码规范的库,目前自己用着pycharm自带的就挺好用,如果用各种第三方库往往还需要配置有点麻烦
Issue #494 Python Secures TIOBE #1 Spot, Guido on Python Performance, 3.10 Updates, and More Oct. 12, 2021¶
Beating C and Java, Python Becomes the #1 Most Popular Programming Language, Says TIOBE
ZDNet reports that Python “is now the most popular language, according to one popularity ranking.” “For the first time in more than 20 years we have a new leader of the pack…” the TIOBE Index announced this month. “The long-standing hegemony of Java and C is over.”
SLASHDOT.ORG
登顶
Python C API: Add Functions to Access PyObject
“The PyObject structure prevents indirectly to optimize CPython. We will see why and how I prepared the C API to make this structure opaque. It took me 1 year and a half to add functions and to introduce incompatible C API changes (fear!)”
VICTOR STINNER
看起来是个大工程,正好最近在看python behind the scenes
Guido van Rossum on Improving Python’s Performance
SOFTWARE AT SCALE PODCAST
俩人搁这唠半天也没说出个啥
Issue #495 GIL-Free CPython Proof of Concept, Type Hints Case Study, Using @property, and More Oct. 19, 2021¶
No-GIL Fork of CPython
This is a proof-of-concept implementation of CPython that supports multithreading without the global interpreter lock (GIL), from Facebook research. An overview of the design is described in the Python Multithreading without the GIL Google doc. Also see the related discussions on LWN and Hacker News.
GITHUB.COM/COLESBURY • Shared by Henry Schreiner
这是 CPython 的概念验证实现,它支持多线程而无需全局解释器锁 (GIL)。设计的概述在没有 GIL 的 Python 多线程 Google 文档中进行了描述。 这是文档 https://docs.google.com/document/d/18CXhDb1ygxg-YXNBJNzfzZsDFosB5e6BfnXLlejd9l0/edit
Tests Aren’t Enough: Case Study After Adding Type Hints to urllib3
“Since Python 3.5 was released in 2015 including PEP 484 and the typing module type hints have grown from a nice-to-have to an expectation for popular packages. To fulfill this expectation our team has committed to shipping type hints for the v2.0 milestone. What we didn’t realize is the amount of value we’d derive from this project in terms of code correctness.”
SETH MICHAEL LARSON
urllib3加hint的过程
Python’s property(): Add Managed Attributes to Your Classes
In this step-by-step tutorial, you’ll learn how to create managed attributes, also known as properties, using Python’s property() in your custom classes. REAL PYTHON
用property来实现其他语言中的get和set方法
# circle.py
class Circle:
def __init__(self, radius):
self._radius = radius
def _get_radius(self):
print("Get radius")
return self._radius
def _set_radius(self, value):
print("Set radius")
self._radius = value
def _del_radius(self):
print("Delete radius")
del self._radius
radius = property(
fget=_get_radius,
fset=_set_radius,
fdel=_del_radius,
doc="The radius property."
)
上面这种还是感觉有点太啰嗦了,还是下面这种感觉更优雅
# circle.py
class Circle:
def __init__(self, radius):
self._radius = radius
@property
def radius(self):
"""The radius property."""
print("Get radius")
return self._radius
@radius.setter
def radius(self, value):
print("Set radius")
self._radius = value
@radius.deleter
def radius(self):
print("Delete radius")
del self._radius
可以来创建一些属性(只读、只写之类的)或者进行校验
# point.py
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
@property
def x(self):
return self._x
@x.setter
def x(self, value):
try:
self._x = float(value)
print("Validated!")
except ValueError:
raise ValueError('"x" must be a number') from None
@property
def y(self):
return self._y
@y.setter
def y(self, value):
try:
self._y = float(value)
print("Validated!")
except ValueError:
raise ValueError('"y" must be a number') from None
Issue #496 Idiomatic Python, GIL Removal Meeting, PyCon 2022, Django 4.0, and More Oct. 26, 2021¶
Writing Idiomatic Python
What are the programming idioms unique to Python? This course is a short overview for people coming from other languages and an introduction for beginners to the idiomatic practices within Python. You’ll cover truth values, looping, DRY principles, and the Zen of Python.
REAL PYTHON COURSE
Python常见操作,入门课程
Notes From the Meeting on Python GIL Removal Between Python Core and Sam Gross
“During the annual Python core development sprint we held a meeting with Sam Gross, the author of nogil, a fork of Python 3.9 that removes the GIL. This is a non-linear summary of the meeting.”
ŁUKASZ LANGA
永远有人在针对GIL,道阻且长。如果能在3.9上测试成功,那么应该未来是可以合并到main上的,不过肯定也是个长期的过程
PEP 660: Editable Installs for pyproject.toml Based Builds (Wheel Based)
“Now that PEP 517 provides a mechanism to create alternatives to setuptools, and decouple installation front ends from build backends, we need a new mechanism to install packages in editable mode.”
PYTHON.ORG
pip install -e .
Using the “not” Boolean Operator in Python
In this step-by-step tutorial, you’ll learn how Python’s “not” operator works and how to use it in your code. You’ll get to know its features and see what kind of programming problems you can solve by using “not” in Python.
REAL PYTHON
>>> # Bad practice
>>> not "c" in ["a", "b", "c"]
False
>>> # Best practice
>>> "c" not in ["a", "b", "c"]
False
nMigen: Python Toolbox for Building Complex Digital Hardware
GITHUB.COM/NMIGEN
好像是个硬件编程的库
DearPyGui 1.0.0: A GPU Accelerated Python GUI Framework
GITHUB.COM/HOFFSTADT
感觉挺好用的,看着界面也还可以,找时间学一学
Issue #497 GIL News, "zipapp" Module in 3.5+, PSF Community Service Awards, and More Nov. 2, 2021¶
A Viable Solution for Python Concurrency
“The end result thus appears to be a GIL-removal effort that has a rather better-than-average chance of making it into the CPython interpreter. That would be cause for a lot of rejoicing among Python developers. That said, a change this fundamental is unlikely to be rushed into the CPython mainline; it will take a lot of testing to convince the community that it is ready for production use.”
JONATHAN CORBET
加油!
Python’s zipapp Module: Build Executable Zip Applications
In this step-by-step tutorial, you’ll learn what Python Zip applications are and how to create them quickly using the zipapp module from the standard library. You’ll also learn some alternative tools you can use to build this kind of application manually.
REAL PYTHON
又是一种分发的方式,不过感觉还是pyinstaller更合理
Is the Key Order the Same for OrderedDict and dict?
STACK OVERFLOW
如果只是使用插入有序这个特性的话,没有区别。不过由于dict是数组实现,order dict是链表实现,所以在某些地方还是有一些区别的。不过大多数情况下还是不用关心的
detr: End-to-End Object Detection With Transformers
GITHUB.COM/FACEBOOKRESEARCH
从来没听过这个,比yolox star还多。看了一会知乎,论文还不算太新,效果其实还好,不过问题是太吃显存普通人不是很好训练。感觉得等等简化一波才能落地应用吧
Issue #498 Custom Python for Banks, CLI Apps With Typer, Faster CPython, and More Nov. 9, 2021¶
Build a Command-Line To-Do App With Python and Typer
Follow along this step-by-step project to create a to-do application for your command line using Python and Typer. While you build this app, you’ll learn the basics of Typer, a modern and versatile library for building command-line interfaces (CLI).
REAL PYTHON
在用,很好用
What’s the Difference Between str.isdigit, isnumeric and isdecimal?
STACK OVERFLOW
好像跟unicode有点关系,大概率用不到, 用到了再踩坑
Making Python Faster With Guido and Mark
“This episode is the first of several that dive into some of the active efforts to increase the speed of Python while maintaining compatibility with existing code and packages. Who better to help kick this off than Guido van Rossum and Mark Shannon?”
TALK PYTHON PODCAST
更好、更快
Issue #499 Deploying Django, Become the Next PSF Director, Ruby vs Python, and More Nov. 16, 2021¶
How Python’s list Data Structure Really Works
This article explores the nuts and bolts of Python list operations, their time complexity, and underlying data structures.
ANTON ZHIYANOV • Shared by Anton Zhiyanov
一些小的介绍
Async Python Is Not Faster
“Async Python is slower than ‘sync’ Python under a realistic benchmark. A bigger worry is that async frameworks go a bit wobbly under load.”
CAL PATERSON
异步框架可能没有他们宣传的那么好
Issue #500 Python News Roundup, Web Performance Benchmarking, Static Duck Typing, and More Nov. 23, 2021¶
Spack: A Flexible Package Manager
SPACK.READTHEDOCS.IO
包管理工具
objprint: Print Python Objects in Human Readable Format
GITHUB.COM/GAOGAOTIANTIAN • Shared by Tian Gao
整挺好