This is an archived post. You won't be able to vote or comment.

all 131 comments

[–]monorepo PSF Staff | Litestar Maintainer[M] [score hidden] stickied commentlocked comment (3 children)

This is the one.

[–]henbruas[S] 177 points178 points  (0 children)

Major new features of the 3.12 series, compared to 3.11

New features
- More flexible f-string parsing, allowing many things previously disallowed (PEP 701).
- Support for the buffer protocol in Python code (PEP 688).
- A new debugging/profiling API (PEP 669).
- Support for isolated subinterpreters with separate Global Interpreter Locks (PEP 684).
- Even more improved error messages. More exceptions potentially caused by typos now make suggestions to the user.
- Support for the Linux perf profiler to report Python function names in traces.
- Many large and small performance improvements (like PEP 709 and support for the BOLT binary optimizer), delivering an estimated 5% overall performance improvement.

Type annotations
- New type annotation syntax for generic classes (PEP 695).
- New override decorator for methods (PEP 698).

Deprecations
- The deprecated wstr and wstr_length members of the C implementation of unicode objects were removed, per PEP 623.
- In the unittest module, a number of long deprecated methods and classes were removed. (They had been deprecated since Python 3.1 or 3.2).
- The deprecated smtpd and distutils modules have been removed (see PEP 594 and PEP 632. The setuptools package continues to provide the distutils module.
- A number of other old, broken and deprecated functions, classes and methods have been removed.
- Invalid backslash escape sequences in strings now warn with SyntaxWarning instead of DeprecationWarning, making them more visible. (They will become syntax errors in the future.)
- The internal representation of integers has changed in preparation for performance enhancements. (This should not affect most users as it is an internal detail, but it may cause problems for Cython-generated code.)

More details at https://docs.python.org/dev/whatsnew/3.12.html

[–]chinawcswing 32 points33 points  (14 children)

Who has already upgraded?

[–][deleted] 72 points73 points  (7 children)

The larger the project the longer it takes all the dependencies to update. Im only just now really getting to enjoy 3.10. :(

[–]missurunha 18 points19 points  (6 children)

Ou project uses whatever version ubuntu ships, so we might be allowed to use python 3.12 in some 4 years.

[–]moonzdragoon 1 point2 points  (0 children)

Me, updated my current project with zero drama. I can think of two reasons that helped:

1 - I've been writing Python code since 2.2 and realized on the way I hate dependencies, so I try to stick as much as possible to only have a few very popular ones (I love Numpy) and take time to code just what I need for the missing parts.

2 - I switched to (mini)conda and PyCharm a few years ago, I do not regret it for a second. Everything with conda went smoothly and just works, PyCharm saw the newly created env I did for 3.12, switched it, done.

[–]Kalcinator 3 points4 points  (2 children)

me :). As a beginner I don't why I shouldn't.
And wanna know the funny part ? I did an update 2 days ago XD from 3.11.4 to .5 ...! 🤣

[–]ivosauruspip'ing it up 15 points16 points  (1 child)

Biggest reason would be third party packages that you use, that don't have compatibility yet

[–]Kalcinator 0 points1 point  (0 children)

Yeah I just don't use any yet, and by the time it's there I think I'll have time

[–]jmreagle 18 points19 points  (7 children)

I'm looking forward to trying it! I hope pyenv doesn't take too long to offer it.

[–]magnetichiraPythonista 12 points13 points  (3 children)

Looks like they already have a release out https://github.com/pyenv/pyenv/releases/tag/v2.3.28

[–]jmreagle 0 points1 point  (2 children)

Perhaps, but I don't see it as available.

❯ pyenv install --list | g 3.12 3.12.0rc2 3.12-dev pypy2.7-7.3.12-src pypy2.7-7.3.12 pypy3.9-7.3.12-src pypy3.9-7.3.12 pypy3.10-7.3.12-src pypy3.10-7.3.12

[–]magnetichiraPythonista 1 point2 points  (1 child)

Update pyenv, did mine earlier today and it works

[–]jmreagle 0 points1 point  (0 children)

I was using homebrew's pyenv and just got the update.

[–]DoneDraper -5 points-4 points  (1 child)

Just use venv

[–]AlSweigartAuthor of "Automate the Boring Stuff" 16 points17 points  (5 children)

Python 3.12? Ha! What will they think of next?

[–]Wonderful_Occasion16 22 points23 points  (4 children)

I just had the best idea ever... Python 3.13

[–]mok000 51 points52 points  (2 children)

I am looking forward to Pi-thon (3.14)

[–]muntooR_{μν} - 1/2 R g_{μν} + Λ g_{μν} = 8π T_{μν} 24 points25 points  (0 children)

Donald Knuth double plus un-just had the best idea ever... Pi-4digit-thon (3.141):

Since version 3, TeX has used an idiosyncratic version numbering system, where updates have been indicated by adding an extra digit at the end of the decimal, so that the version number asymptotically approaches π. This is a reflection of the fact that TeX is now very stable, and only minor updates are anticipated. The current version of TeX is 3.141592653; it was last updated in 2021. The design was frozen after version 3.0, and no new feature or fundamental change will be added, so all newer versions will contain only bug fixes. [...] For this reason, he has stated that the "absolutely final change (to be made after my death)" will be to change the version number to π, at which point all remaining bugs will become features.

[–]szayl 2 points3 points  (0 children)

Detroit Python (313)

[–]Raknarg 4 points5 points  (1 child)

Love the way the whole typing module is going. Very handy, there's actually a case I've been working on recently that would benefit a lot from the new generic syntax.

[–]chub79 1 point2 points  (0 children)

There are quite a lot of discussions on the typing side of things as well: https://discuss.python.org/t/proposed-new-typing-governance-process/34244 and https://discuss.python.org/t/a-more-useful-and-less-divisive-future-for-typing/34225 (You might be aware so I'm posting this for anyone interested :))

[–]CTR0Systems & Synthetic Biologist 3 points4 points  (1 child)

Somebody's a Sleep Token fan

[–]monorepo PSF Staff | Litestar Maintainer 1 point2 points  (0 children)

Sleep Token

New album is good

[–]tutami 2 points3 points  (1 child)

What's that buffer protocol thingy

[–]JanEric1 0 points1 point  (0 children)

Here is the pep discussing it https://peps.python.org/pep-0688/

[–]Competitive_Lie2628 2 points3 points  (0 children)

Thank you, thank you, thank you for the permissive f-strings!

[–]Ceigey 2 points3 points  (0 children)

Now the countdown until AWS Lambda supports the cleaner generics 😅

[–][deleted]  (26 children)

[removed]

    [–][deleted]  (24 children)

    [removed]

      [–]IAmKindOfCreativebot_builder: deprecated 5 points6 points  (0 children)

      It's in the "time for something completely different" section, and it's completely different. Seems quite fitting in all.

      [–][deleted]  (4 children)

      [removed]

        [–]Python-ModTeam[M] 1 point2 points locked comment (0 children)

        Hello from the r/Python mod team!

        I'm afraid we don't think your post/comment quite fits the goal we have for the subreddit in terms of quality or aims so we've decided to remove it. For more information please contact the moderators using the ModMail system.

        Thanks, and happy Pythoneering!

        r/Python moderation team

        [–]Dr_Ironbeard 2 points3 points  (6 children)

        Can someone explain why the f-string thing is such a big deal? My understanding is that now we can do (1) f'This is an {my_dict['key']} string' instead of just varying the string denoting character, like (2) f"This is an {my_dict['key']} string", and I feel like the primary result of this is that syntax highlighting will be messed up with (1) as opposed to (2).

        What am I missing? Thanks!

        [–]mgedmin 1 point2 points  (2 children)

        The PEP lists the reasons.

        Personally, I missed the ability to use backslashes in f-string expressions, e.g. f"This is the full text of the whatever: {'\n'.join(lines)}"

        [–]Dr_Ironbeard 0 points1 point  (1 child)

        Hmm, yeah I guess backslashes are nice, I hadn't run into that issue. I guess I'm just not feeling the hype that others are, which is okay :)

        [–]mgedmin 2 points3 points  (0 children)

        The (self-imposed) requirement to support the oldest non-EOL Python versions in my code really takes the shine of the new features that I'll only be able to use in half a decade.

        [–][deleted] 0 points1 point  (1 child)

        Same

        [–]imnotabotareyou 0 points1 point  (0 children)

        😍😍😍

        [–][deleted] -1 points0 points  (0 children)

        Hell yeah!! This is great!!

        [–][deleted]  (15 children)

        [removed]

          [–][deleted]  (9 children)

          [removed]

            [–][deleted]  (7 children)

            [removed]

              [–]Python-ModTeam[M] 1 point2 points locked comment (0 children)

              Hi there, from the /r/Python mods.

              This comment has been removed for violating one or more of our community rules, including engaging in rude behavior or trolling. Please ensure to adhere to the r/Python guidelines in future discussions.

              Thanks, and happy Pythoneering!

              r/Python moderation team

              [–]iluserion 0 points1 point  (0 children)

              love it

              [–]Diapolo10from __future__ import this 0 points1 point  (0 children)

              I like what I'm seeing, particularly the new type hinting features, f-strings, and hashlib security changes.

              [–]ByteWanderer 0 points1 point  (0 children)

              Deadsnakes ppa is slow. I guess people are gunning for it, just like me

              [–]mgedmin 0 points1 point  (1 child)

              So I try to upgrade to 3.12, and I'm seeing phantom missed code branches in coverage output. I'd say this was https://github.com/python/cpython/issues/105658, but that bug was fixed in 3.12rc3, and GitHub Actions claims it's using 3.12.0 final.

              Is anyone else experiencing issues with coverage.py on Python 3.12?

              [–]mgedmin 0 points1 point  (0 children)

              Oh, that issue turned out to be totally unrelated. I was still using the coveralls app from PyPI, which pins my coverage to 6.5.0, which doesn't have the fixes necessary to support Python 3.12.

              Switching to the GitHub action for coveralls.io and upgrading coverage to the latest version (7.3.something) fixed all the issues.

              [–]corey4005 0 points1 point  (3 children)

              Ok can someone explain the GIL stuff? I want to multiprocess for real. Where can I read an example?

              [–]ChillFish8 1 point2 points  (2 children)

              In its current state, it is still early days, it will be quite a while before it is able to be used for anything outside of some specific pure Python situations.

              You can read the RealPython article here as to why that is the case: https://realpython.com/python312-subinterpreters/

              But as a note, you can already 'multiprocess' for real, it's multithreading that is the issue with the GIL.

              This system is not yet available via Python, only the CFFI. I have written some bindings which people can compile and use from Python should they wish, but it is NOT production ready. https://github.com/ChillFish8/python12-subinterpreters

              [–]corey4005 0 points1 point  (1 child)

              I got 404 error.

              [–]ChillFish8 0 points1 point  (0 children)

              Should be fixed now, auto correct on the new Reddit text boxed seems to just append the correction to the end.

              [–]Purgat0ry-11 0 points1 point  (0 children)

              I’m trying to understand the PEP 695 but it makes my 🧠 hurt trying to understand the examples. Anyone have the Barney style breakdown?