What's new in Python 3.13?

Sdílet
Vložit
  • čas přidán 28. 05. 2024
  • The Python 3.13 beta has been released, meaning the feature freeze is now active. This is the perfect time to take a minute to see what's new and upcoming in the release, so let's dive into it!
    Below is a list of chapters cited against any relevant references which you'll find further down. It's absolutely worth doing further reading using these if you want to learn more!
    Chapters:
    0:00 - Intro
    0:30 - JIT compilation [1-3]
    1:29 - Adding iOS as a supported platform [4-5]
    1:49 - Improved error messages [6-7]
    2:11 - Marking deprecations using the type system [8]
    2:30 - Deferred evaluation of annotations using descriptors [9-10]
    3:17 - Narrowing types with TypeIs [11]
    3:52 - Things no longer coming to 3.13 [12-13]
    4:06 - Quickfire cool stuff! [14]
    4:42 - Outro
    References:
    [1] peps.python.org/pep-0744
    [2] tonybaloney.github.io/posts/p...
    [3] dl.acm.org/doi/10.1145/3485513
    [4] peps.python.org/pep-0730
    [5] peps.python.org/pep-0738
    [6] • Python now has COLOURE...
    [7] docs.python.org/3.13/whatsnew...
    [8] github.com/python/cpython/blo...
    [9] peps.python.org/pep-0563
    [10] peps.python.org/pep-0649
    [11] peps.python.org/pep-0742
    [12] peps.python.org/pep-0734
    [13] peps.python.org/pep-0712
    [14] docs.python.org/3.13/whatsnew...
    -
    If you enjoy my content, consider supporting me on Patreon or becoming a member!
    • Patreon: / carberra
    • Membership: / @carberra
    Follow me elsewhere for even more Carberra!
    • Discord: / discord
    • Instagram: / carberratutorials
    I get a lot of people asking, so here's my setup!
    • Visual Studio Code: • My Visual Studio Code ...
    • Terminal: • Make your terminal loo...
    -
    If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.
    #python #coding #howto

Komentáře • 94

  • @Carberra
    @Carberra  Před 21 dnem +7

    If you're looking for more juicy details about 3.13, including the GIL-less Python builds, check out my first look video! czcams.com/video/e4HOCuJfbGY/video.html
    Thanks for stopping by!

  • @Its2Reel4U
    @Its2Reel4U Před 21 dnem +373

    Will version 3.14 run under the name Pi-thon?

    • @Carberra
      @Carberra  Před 21 dnem +28

      Doesn't look as though anyone has made any official references as yet! Surely they will at some point. We'll have to keep our eyes peeled!

    • @sujalgarewal2685
      @sujalgarewal2685 Před 21 dnem +10

      It will be Py-π

    • @Emayeah
      @Emayeah Před 21 dnem +25

      ​@@sujalgarewal2685 nah more like π-thon

    • @atommax_1676
      @atommax_1676 Před 20 dny +1

      Sounds like russian pronunciation

    • @DennisJ42
      @DennisJ42 Před 20 dny

      Hah. I like it. (The pun I mean)

  • @Anonymous-6598
    @Anonymous-6598 Před 22 dny +43

    Finally support for IOS and Android

    • @vinylSummer
      @vinylSummer Před 21 dnem +1

      I wonder how android apps like Pydroid work 🤔

    • @Anonymous-6598
      @Anonymous-6598 Před 21 dnem

      @@vinylSummer, same question

    • @vinylSummer
      @vinylSummer Před 21 dnem

      @@Anonymous-6598 I googled it. There's a python-for-android lib that does some smart cross-compilation magic, so there's at least that

    • @No_True_Scotsman
      @No_True_Scotsman Před 21 dnem +1

      What do they mean by that? There's going to be an interpreter app? Or a library to run python inside other apps?

    • @MangoNutella
      @MangoNutella Před 20 dny +1

      ​@@vinylSummer I think it's because Android is just a Linux distribution on which Python can be installed.

  • @pythonwithjames
    @pythonwithjames Před 21 dnem +9

    Nice one for this! Loved the work on Improved error messages.

    • @Carberra
      @Carberra  Před 21 dnem +1

      Yeah, lot of nice quality of life updates in errors for sure!

  • @carlosmspk
    @carlosmspk Před 22 dny +31

    As someone who likes to split packages into a lot of files, the cyclical import update is amazing.

    • @Carberra
      @Carberra  Před 21 dnem +1

      Cyclical import update?

    • @carlosmspk
      @carlosmspk Před 21 dnem +1

      @@Carberra Oh nevermind, it only impacts circular references for the purposes of type annotations (I meant circular, not cyclical btw). Seems circular imports are here to stay (which would make sense)

    • @Carberra
      @Carberra  Před 21 dnem +1

      I wasn't sure if you meant that or whether you'd come across something amazing I'd missed lmao. Yeah the lazy imports PEP (which wouldn't taken out circular imports for good) was rejected some time in 3.12's development, so yeah, they're here to stay unfortunately 😔

  • @mihailyanchev1905
    @mihailyanchev1905 Před 18 dny

    Thanks for the useful info 🙏🏼

  • @WhiteDoppler
    @WhiteDoppler Před 21 dnem +1

    Distributions of python 3.13 will come with an optional additional binary (python3.13t) where the GIL is disabled. It's a checkbox in the windows installer, but it's going to be up to package maintainers to figure out how to distribute on other platforms

    • @Carberra
      @Carberra  Před 21 dnem +1

      Indeed! I didn't include it in the video as I'd covered it before and there hasn't been any major updates since, but it looks to be coming along very nicely. Hopefully it's all ready to go for the final release!

  • @c4llv07e
    @c4llv07e Před 21 dnem +9

    XDG base directory support is my favourite one.

    • @Lizardboythelazy
      @Lizardboythelazy Před 21 dnem +1

      Where is this? I don't see a mention of it in the release notes.

  • @tswdev
    @tswdev Před 16 dny +1

    2:31 this seems like perhaps the most important new thing on 3.13, I didnt fully understand the description but if it is what I think it is, this fixes the biggest downside to Python when compared to other "more mature" languages. I put that in quotes because the import system in python is extremely immature and the biggest issue it caused was not being able to use types anywhere we would like because of the need for imports. Hacks had to be used, like a import guard for only importing a type at "type checking" time. Which is a PITA do maintain. Hopefully this fixes that

    • @Carberra
      @Carberra  Před 15 dny +1

      I don't believe this change will resolve that, if you mean what I think you mean. You'll still to import types, though there'll be less of a need to import types at runtime. Still won't nullify all the benefits of that though.

  • @fabianramirez3222
    @fabianramirez3222 Před 11 dny

    The only feature after security patches in upcoming python versions is backwards compatibility, which seems to be missing since... always...

  • @AsgerJon
    @AsgerJon Před 21 dnem +7

    lmao, how can the jit provide such a small improvement? I recall numba being like orders of magnitude faster.

    • @betterinbooks
      @betterinbooks Před 21 dnem

      I also would like an explanation on this.

    • @ilikeshiba
      @ilikeshiba Před 21 dnem +2

      Because it’s basically just like an inlined continuation passing style chained function call JIT. If your interpreter is well written and your language has fundamentally slow semantics (like python) you won’t see much gain from something like this.
      The reason JITs are fast is due to optimization and speculative optimization especially for dynamic languages. This style of JIT does neither. The generated code still treats every variable as what it is: a big dynamic blob of memory that you can’t assume much about. So basically we’re only seeing the time to find the next byte code instruction and some function call overhead within the interpreter optimized out.
      I’m very surprised to learn that this style of JIT is “new” though. Maybe it wasn’t formally described until 2021 but I’ve literally written (half of) a JIT for a toy gameboy emulator that works the exact same way because it’s so obvious and easy.

    • @AsgerJon
      @AsgerJon Před 21 dnem

      @@ilikeshiba But numba-jit provides an improvement at like orders of magnitude, why does this jit give us only 10 % or whatever it was?

    • @ilikeshiba
      @ilikeshiba Před 20 dny

      @@AsgerJon I’m not personally familiar with it but from a quick glance at their website, numba is optimizing and using LLVM. It’s unclear if it’s doing any speculative optimization but even without speculative optimization, knowing the order of instructions would allow optimizations like reordering instructions, possibly vectorizing, reallocating registers to avoid register spills, removing duplicated work between bytecode instructions, and fusing instructions together in some cases. LLVM is much, much, much higher overhead in terms of code shipped and time spent compiling your code than the simple technique CPython is using.
      The main appeal of JITs like the one that CPython is shipping is that they’re simple and obviously correct and you’ll pretty much never spend more time running the JIT than you will gain by having done it.
      I think CPython is more concerned about strictly following the spec and being simple than being fast. Faster alternative compilers will still have a place for less conservative users that don’t mind more (potential) breakage or heavier python runtimes with more potential bugs for speed.
      But if it’s as fast as you say then they probably are able to, either speculatively or by changing the semantics of Python, optimize types into simpler ones that can be run quickly. I’m not 100% sure but I assume Int is an object on the heap that works as an arbitrary precision integer without any extra optimizations in CPython. In numba they probably give you access to either a fixed bitwidth number type implicitly or explicitly and can use that alone to get massive speed ups and even further optimizations that will just never be possible otherwise. It can change what would be multiple virtual function calls on an object on the heap doing lots of work into 1 or 2 machine instructions operating on a register.

    • @TheArtikae
      @TheArtikae Před 20 dny +1

      @@AsgerJon???? They explained exactly why in the comment you’re replying to.

  • @kokop1107
    @kokop1107 Před 19 dny +3

    Ios being added BEFORE Android? Now that is funny to me lmao

  • @codeguy7309
    @codeguy7309 Před 21 dnem +31

    now python is slower even faster

  • @MasterSergius
    @MasterSergius Před 19 dny

    Wait, we can't migrate to 3.12 because of dependencies and now you present 3.13?

  • @rkdeshdeepak4131
    @rkdeshdeepak4131 Před 21 dnem +6

    On android , it already compiles on termux.

  • @alikhatami6610
    @alikhatami6610 Před 19 dny +3

    I didn't understand a thing! Am I that bad of a programmer ?

    • @kaiser2261
      @kaiser2261 Před 15 dny +1

      He went kind of fast but if you understood literally nothing I’d recommend reading one of the O Reilly Python textbooks.

  • @guilherme5094
    @guilherme5094 Před 21 dnem

    👍

  • @MrAlanCristhian
    @MrAlanCristhian Před 21 dnem +3

    I want to know more about the new Incremental Garbage Collection

    • @Carberra
      @Carberra  Před 21 dnem +4

      It basically just collects small parts over time rather than the whole heap at once. I didn't include it in the video as I couldn't find any performance comparisons between the two systems.

  • @jamesarthurkimbell
    @jamesarthurkimbell Před 20 dny

    The TypeIs/TypeGuard stuff feels like it should be a part of pattern matching

    • @Carberra
      @Carberra  Před 20 dny +1

      You can actually use built-in functions like dict(), int() etc. to do that! (I think anyways, I've seen it, never tried it personally.)

    • @jamesarthurkimbell
      @jamesarthurkimbell Před 20 dny

      @@Carberra Yeah, I've done that. But I don't know if it helps type checkers narrow down their analysis as much as these tools (otherwise why would they exist?). Or maybe it's just people coming from TypeScript and wanting to do things a certain way

  • @unvergebeneid
    @unvergebeneid Před 6 dny

    Solaris still exists?! 😄

  • @JarppaGuru
    @JarppaGuru Před 21 dnem

    dont know whats removed? lol 3.14 coming

  • @dwight4k
    @dwight4k Před 22 dny +1

    653 or 563?

    • @Carberra
      @Carberra  Před 22 dny +3

      It is 563, sorry. I've watched this so many times and missed that! Thanks for pointing that out.

    • @dwight4k
      @dwight4k Před 22 dny +2

      @@Carberra No problem. Great video.

  • @lbgstzockt8493
    @lbgstzockt8493 Před 21 dnem +2

    I wish python would stop using global variables in function definitions unless explicitly told to, like in C++. I didn’t know it did this until it caused a really annoying to fix error for me, and just seems unintuitive.

  • @ivankramarenko
    @ivankramarenko Před 21 dnem

    wthell 2k.... may be in 3k it will good(not)

  • @seansingh4421
    @seansingh4421 Před 15 dny

    Ha Good luck ever running it properly now since the 24.04 LTS fckin broke pip.

    • @Carberra
      @Carberra  Před 15 dny

      Did it? How so?

    • @seansingh4421
      @seansingh4421 Před 15 dny

      @@Carberra pip install soandso used to work perfectly. Now its returns env and permission error for everything, on a local admin account 😑😑

    • @TedMan55
      @TedMan55 Před 6 dny

      @@seansingh4421curious to hear more about this, i just built a server running 24.04 and curious to hear how it went

  • @aristonsaizoxic1048
    @aristonsaizoxic1048 Před 22 dny +4

    I wish pyscript would become mainstream.....i don't want to learn another language for front end.

    • @matis9783
      @matis9783 Před 21 dnem

      Xd

    • @ewerybody
      @ewerybody Před 21 dnem

      what's a pyscript?

    • @yashdeveloper9449
      @yashdeveloper9449 Před 21 dnem

      ​@@ewerybodyjavascript but py

    • @Carberra
      @Carberra  Před 21 dnem +1

      I'm plugging myself a lot in the comments today apparently, but I made a video on PyScript if you want to know more: czcams.com/video/VD2s23JgE7I/video.html

    • @MrZmogZ
      @MrZmogZ Před 21 dnem

      There is transcrypt

  • @afterschool2594
    @afterschool2594 Před 12 dny

    Nah, I am waiting for πthon

  • @djtomoy
    @djtomoy Před 21 dnem

    2.7 4 life

  • @pikadroo
    @pikadroo Před 21 dnem

    Oh are you gonna tell us how all our code will break. Get off my feed!

  • @ButchCassidyAndSundanceKid

    Get rid of the GIL !

    • @themartdog
      @themartdog Před 22 dny

      Isn't there a GIL-less build as of 3.12?

    • @Carberra
      @Carberra  Před 22 dny +3

      If you're curious, there looks to be a label on GitHub specifically for this work: github.com/python/cpython/pulls?q=is%3Apr+label%3Atopic-free-threading+
      I didn't talk about it this time cos there wasn't really much to add over what I've discussed before, but it looks to be coming along rather well!

    • @Carberra
      @Carberra  Před 22 dny +3

      @themartdog The 3.12 GIL-less build was an unofficial prototype, a proof-of-concept kinda thing. The 3.13 one is (planned to be) a much more feature-complete thing. I'm not quite sure how far along they are at the moment.

    • @jonragnarsson
      @jonragnarsson Před 22 dny +2

      What has Gil ever done to you?

    • @ButchCassidyAndSundanceKid
      @ButchCassidyAndSundanceKid Před 22 dny +2

      @@jonragnarsson You should rephrase what has GIL hasn't ever done to you.