GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing iscinumpy.dev — Python 3.12 Python 3.12’s beta’s are out, which means the features are locked in. The theme
this year has been cleanup and typing. Faster CPythonThe faster CPython project is still working on features, though most of the changes this time around don’t seem to affect daily performance as much as 3.11 did. A lot of work went into the per interpreter GIL, which will be covered in its own section later. There still are some nice user-facing improvements though. Comprehensions are now inlined, making them up to 2x faster. This does affect
scoping inside comprehensions; just in case you are using
Error messagesThe suggestion features keep getting better, based heavily on reports from
people teaching Python about common mistakes. Trying to use a stdlib module
without importing it, reversing the order of TypingGenericsThere were a lot of typing improvements this round, including a brand new syntax for generics! This is common in other statically-typed languages, but might seem a bit odd if you’ve not seen one of those before. Here’s an example, compared with the classic TypeVar method, and C++: Bounds and constraints are supported too: And you can also make generic type aliases in one line: This also works if the type alias is not generic, so most usage of Unlike most typing improvements, this is not available in older Python versions,
even with Other typing improvementsYou can now use a There’s now a
Native f-stringsF-strings are now a native part of the syntax rather than a thousand-plus line hack on strings. This means the following is now valid: The nested quotes are fine, because the stuff inside the brackets is normally parsed Python! Multiple lines, escape codes, all that stuff now works like normal Python, and not like string contents. This also means error messages now look like normal Python and can access the correct places in the line(s). And tokenizing the f-strings for parsing is 64% faster! Per-interpreter GILOne of the biggest features, and one with possibly the most performance potential, is the per-interpreter GIL. This is a rather odd new feature, though, because it landed without a Python interface; you have to use the C API for now. Though don’t worry, there will be a first-party PyPI module providing a Python API, and that will help guide the development of a proper standard library API, probably in 3.13. The API will probably look something like this: This would also integrate with threading: The interpreters-3-12 module on PyPI contains initial work for this. There are other plans and hopes, like a dedicated API for data passing, but that’s the core idea for now. These interpreters each have their own GIL, so that means that with effort, you can run Python fully multithreaded in a single process! See the examples in ericsnowcurrently/interpreters for more. Other featuresThe buffer protocol can now be used from Python, with
RemovalsDistutils has been removed from the standard library. Setuptools is no longer
installed by default when you make a new Dropping this in with your current Other removed libraries include Other Developer changesAs usual, there are some more technical changes that will excite some people:
Final WordsIf you are using GitHub Actions, the new and best way to add 3.12 is to use this: This works in a matrix, etc. too. Also, note that setup-python recently started supporting setting up multiple Python’s at once, with a range - very useful if you are using nox or tox, for example. And if you are using cibuildwheel, we’ve supported this since beta 1 with the following flag: If you are using NumPy, you might be in for a wait. The just-released version of numpy (1.25) does not support Python 3.12; the next release (1.26) will complete the migration to a new build backend, and is supposed to come up “when 3.12 is released”. I don’t know if that means final release, RC 1, or some future beta. Sources and other linksCategories: Python |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |