Veit Schiele
Cusy GmbH, Berlin
Python Users Berlin, 10 March 2022
On Monday, 7 March, Python 3.11 a6 was released
Final release of Python 3.11 is planned for October 2022,
The traceback contains visual feedback about the exact location in a line that threw an exception, for example
Traceback (most recent call last):
File "test.py", line 2, in <module>
x['a']['b']['c']['d'] = 1
~~~~~~~~~~~^^^^^
TypeError: 'NoneType' object is not subscriptable
Opt-out mechanism
… to save memory and still allow tools to automatically analyse tracebacks:
PYTHONNODEBUGRANGES
python -Xno_debug_ranges
There will be a new exception type called exception group, which will allow multiple exceptions to be grouped into one container. This essentially simplifies error handling in concurrent code, especially with Async IO, but also, for example, when grouping multiple exceptions that occur during data validation.
>>> eg = ExceptionGroup(
... "one",
... [
... TypeError(1),
... ExceptionGroup(
... "two",
... [TypeError(2), ValueError(3)]
... ),
... ExceptionGroup(
... "three",
... [OSError(4)]
... )
... ]
... )
>>> import traceback
>>> traceback.print_exception(eg)
| ExceptionGroup: one (3 sub-exceptions)
+-+---------------- 1 ----------------
| TypeError: 1
+---------------- 2 ----------------
| ExceptionGroup: two (2 sub-exceptions)
+-+---------------- 1 ----------------
| TypeError: 2
+---------------- 2 ----------------
| ValueError: 3
+------------------------------------
This introduces a new variant of the try except syntax to simplify working with exception groups.
*
indicates that multiple exceptions can be handled by each except*
clause:
try:
...
except* SpamError:
...
except* FooError as e:
...
except* (BarError, BazError) as e:
...
See also:
PythonBytes: Episode #271: CPython: Async Task Groups in Python 3.11
PEP 673 wants to introduce a simpler and more intuitive way to annotate methods that return an instance of their class. This corresponds to the TypeVar-based approach in PEP 484 – Type Hints.
Reference implementation: PyRight
See also:
Mypy thread from 2016 talking about ways to tackle the self-typing problem SelfType or another way to spell "type of self" (or, How to define a copy() function).
Variadic generics in the form of TypeVarTuple
want to solve a very special use case in scientific libraries like NumPy and simplify the handling of multidimensional arrays. Thus, the shape of an array is to be defined by parameterising its type with a variable number of placeholder types.
The Steering Committee recently adopted PEP 680, which justifies the need for a TOML parser in the Python standard library, as PEP 517 – A build-system independent format for source trees leads to a new build system based on pyproject.toml
. Previously, packaging tools had to bundle a library to read project metadata from that file.
Note:
The current plan only provides for a TOML parser, without the corresponding serialiser. To write TOML data, an external library must still be installed and imported.
According to Anthony Shaw from the Faster Cpython Project, CPython 3.11 is up to 45% faster at creating instances of base classes and calling methods (most Python code!) 🥳
If you have found a bug in Python 3.11.0 a6, you can currently report it to the Roundup-based Python Bug Tracker (BPO). From 24 March, however, the move to GitHub Issues will begin.
Dates | Events | Notes |
---|---|---|
27-28 April | Tutorials | 150 USD per session; there are two timeslots per day |
28 April | Sponsor Workshops | No entry fee |
28 April | Education Summit | No entry fee |
29 April | Maintainers Summit | No entry fee |
30 April | Mentored Sprints for Diverse Beginners | No entry fee |
30 April | PyLadies Auction | 35 or 50 USD Entry; supporter rates are offered |
See also:
Due to an overlap with a major event in Basel, GeoPython 2022 had to be postponed to 20–22 June 2022.
Other important dates are:
The Python Software Foundation (PSF) is looking to hire two developers to develop new features in the Python Package Index (PyPI). This decision was made after some surveys in the Python community identified the main user requirements that are currently missing in PyPI: the most requested feature was organisational accounts in PyPI. This is to become a paid service offered to companies.
One of the contractors will focus on the back-end while the other will take care of the front-end. Both roles will be location independent and contract work is expected to start in early April 2022. The budget for each role is up to $98k for approximately 560 hours, with 35 hours per working week.
pythoncapi_compat
is now a project of the GitHub Python Organisation¶pythoncapi_compat is used to write a C extension for different Python versions with a single code base.