What's new in Python 3.13?

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

Пікірлер: 94

  • @Carberra
    @Carberra20 күн бұрын

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

  • @Its2Reel4U
    @Its2Reel4U21 күн бұрын

    Will version 3.14 run under the name Pi-thon?

  • @Carberra

    @Carberra

    21 күн бұрын

    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

    20 күн бұрын

    It will be Py-π

  • @Emayeah

    @Emayeah

    20 күн бұрын

    ​@@sujalgarewal2685 nah more like π-thon

  • @atommax_1676

    @atommax_1676

    20 күн бұрын

    Sounds like russian pronunciation

  • @DennisJ42

    @DennisJ42

    19 күн бұрын

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

  • @pythonwithjames
    @pythonwithjames20 күн бұрын

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

  • @Carberra

    @Carberra

    20 күн бұрын

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

  • @Anonymous-6598
    @Anonymous-659821 күн бұрын

    Finally support for IOS and Android

  • @vinylSummer

    @vinylSummer

    20 күн бұрын

    I wonder how android apps like Pydroid work 🤔

  • @Anonymous-6598

    @Anonymous-6598

    20 күн бұрын

    @@vinylSummer, same question

  • @vinylSummer

    @vinylSummer

    20 күн бұрын

    @@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

    20 күн бұрын

    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

    20 күн бұрын

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

  • @carlosmspk
    @carlosmspk21 күн бұрын

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

  • @Carberra

    @Carberra

    21 күн бұрын

    Cyclical import update?

  • @carlosmspk

    @carlosmspk

    21 күн бұрын

    @@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

    21 күн бұрын

    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
    @mihailyanchev190517 күн бұрын

    Thanks for the useful info 🙏🏼

  • @c4llv07e
    @c4llv07e21 күн бұрын

    XDG base directory support is my favourite one.

  • @Lizardboythelazy

    @Lizardboythelazy

    20 күн бұрын

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

  • @WhiteDoppler
    @WhiteDoppler20 күн бұрын

    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

    20 күн бұрын

    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!

  • @tswdev
    @tswdev15 күн бұрын

    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

    15 күн бұрын

    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.

  • @kokop1107
    @kokop110718 күн бұрын

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

  • @codeguy7309
    @codeguy730920 күн бұрын

    now python is slower even faster

  • @jordannewberry9561

    @jordannewberry9561

    7 күн бұрын

    🐍💨

  • @AsgerJon
    @AsgerJon20 күн бұрын

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

  • @betterinbooks

    @betterinbooks

    20 күн бұрын

    I also would like an explanation on this.

  • @ilikeshiba

    @ilikeshiba

    20 күн бұрын

    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

    20 күн бұрын

    @@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

    19 күн бұрын

    @@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

    19 күн бұрын

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

  • @fabianramirez3222
    @fabianramirez322210 күн бұрын

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

  • @guilherme5094
    @guilherme509420 күн бұрын

    👍

  • @MasterSergius
    @MasterSergius18 күн бұрын

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

  • @unvergebeneid
    @unvergebeneid5 күн бұрын

    Solaris still exists?! 😄

  • @jamesarthurkimbell
    @jamesarthurkimbell19 күн бұрын

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

  • @Carberra

    @Carberra

    19 күн бұрын

    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

    19 күн бұрын

    @@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

  • @MrAlanCristhian
    @MrAlanCristhian20 күн бұрын

    I want to know more about the new Incremental Garbage Collection

  • @Carberra

    @Carberra

    20 күн бұрын

    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.

  • @alikhatami6610
    @alikhatami661018 күн бұрын

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

  • @kaiser2261

    @kaiser2261

    14 күн бұрын

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

  • @rkdeshdeepak4131
    @rkdeshdeepak413121 күн бұрын

    On android , it already compiles on termux.

  • @JarppaGuru
    @JarppaGuru20 күн бұрын

    dont know whats removed? lol 3.14 coming

  • @lbgstzockt8493
    @lbgstzockt849320 күн бұрын

    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.

  • @dwight4k
    @dwight4k21 күн бұрын

    653 or 563?

  • @Carberra

    @Carberra

    21 күн бұрын

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

  • @dwight4k

    @dwight4k

    21 күн бұрын

    @@Carberra No problem. Great video.

  • @seansingh4421
    @seansingh442114 күн бұрын

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

  • @Carberra

    @Carberra

    14 күн бұрын

    Did it? How so?

  • @seansingh4421

    @seansingh4421

    14 күн бұрын

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

  • @TedMan55

    @TedMan55

    6 күн бұрын

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

  • @ivankramarenko
    @ivankramarenko20 күн бұрын

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

  • @aristonsaizoxic1048
    @aristonsaizoxic104821 күн бұрын

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

  • @matis9783

    @matis9783

    21 күн бұрын

    Xd

  • @ewerybody

    @ewerybody

    21 күн бұрын

    what's a pyscript?

  • @yashdeveloper9449

    @yashdeveloper9449

    21 күн бұрын

    ​@@ewerybodyjavascript but py

  • @Carberra

    @Carberra

    21 күн бұрын

    I'm plugging myself a lot in the comments today apparently, but I made a video on PyScript if you want to know more: kzread.info/dash/bejne/iHhm1ZRsesqrZ6w.html

  • @MrZmogZ

    @MrZmogZ

    20 күн бұрын

    There is transcrypt

  • @afterschool2594
    @afterschool259411 күн бұрын

    Nah, I am waiting for πthon

  • @djtomoy
    @djtomoy20 күн бұрын

    2.7 4 life

  • @yoyonel1808

    @yoyonel1808

    19 күн бұрын

    😀

  • @danilomenoli

    @danilomenoli

    11 күн бұрын

    Ew brother

  • @pikadroo
    @pikadroo20 күн бұрын

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

  • @ButchCassidyAndSundanceKid
    @ButchCassidyAndSundanceKid21 күн бұрын

    Get rid of the GIL !

  • @themartdog

    @themartdog

    21 күн бұрын

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

  • @Carberra

    @Carberra

    21 күн бұрын

    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

    21 күн бұрын

    @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

    21 күн бұрын

    What has Gil ever done to you?

  • @ButchCassidyAndSundanceKid

    @ButchCassidyAndSundanceKid

    21 күн бұрын

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