What's new in Python 3.13?

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 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

ความคิดเห็น • 97

  • @Carberra
    @Carberra  2 หลายเดือนก่อน +7

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

  • @Its2Reel4U
    @Its2Reel4U 2 หลายเดือนก่อน +416

    Will version 3.14 run under the name Pi-thon?

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +30

      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 2 หลายเดือนก่อน +11

      It will be Py-π

    • @Emayeah
      @Emayeah 2 หลายเดือนก่อน +27

      ​@@sujalgarewal2685 nah more like π-thon

    • @atommax_1676
      @atommax_1676 2 หลายเดือนก่อน +2

      Sounds like russian pronunciation

    • @DennisJ42
      @DennisJ42 2 หลายเดือนก่อน

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

  • @mihailyanchev1905
    @mihailyanchev1905 2 หลายเดือนก่อน

    Thanks for the useful info 🙏🏼

  • @pythonwithjames
    @pythonwithjames 2 หลายเดือนก่อน +9

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

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +1

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

  • @Anonymous-6598
    @Anonymous-6598 2 หลายเดือนก่อน +44

    Finally support for IOS and Android

    • @vinylSummer
      @vinylSummer 2 หลายเดือนก่อน +1

      I wonder how android apps like Pydroid work 🤔

    • @Anonymous-6598
      @Anonymous-6598 2 หลายเดือนก่อน

      @@vinylSummer, same question

    • @vinylSummer
      @vinylSummer 2 หลายเดือนก่อน

      @@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 2 หลายเดือนก่อน +2

      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 2 หลายเดือนก่อน +2

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

  • @carlosmspk
    @carlosmspk 2 หลายเดือนก่อน +36

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

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +1

      Cyclical import update?

    • @carlosmspk
      @carlosmspk 2 หลายเดือนก่อน +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  2 หลายเดือนก่อน +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 😔

  • @c4llv07e
    @c4llv07e 2 หลายเดือนก่อน +9

    XDG base directory support is my favourite one.

    • @Lizardboythelazy
      @Lizardboythelazy 2 หลายเดือนก่อน +1

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

  • @WhiteDoppler
    @WhiteDoppler 2 หลายเดือนก่อน +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  2 หลายเดือนก่อน +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!

  • @fabianramirez3222
    @fabianramirez3222 2 หลายเดือนก่อน

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

  • @MasterSergius
    @MasterSergius 2 หลายเดือนก่อน

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

  • @tswdev
    @tswdev 2 หลายเดือนก่อน +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  2 หลายเดือนก่อน +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.

  • @AsgerJon
    @AsgerJon 2 หลายเดือนก่อน +8

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

    • @betterinbooks
      @betterinbooks 2 หลายเดือนก่อน

      I also would like an explanation on this.

    • @ilikeshiba
      @ilikeshiba 2 หลายเดือนก่อน +3

      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 2 หลายเดือนก่อน

      @@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 2 หลายเดือนก่อน

      @@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 2 หลายเดือนก่อน +1

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

  • @kokop1107
    @kokop1107 2 หลายเดือนก่อน +4

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

  • @guilherme5094
    @guilherme5094 2 หลายเดือนก่อน

    👍

  • @rkdeshdeepak4131
    @rkdeshdeepak4131 2 หลายเดือนก่อน +6

    On android , it already compiles on termux.

  • @unvergebeneid
    @unvergebeneid 2 หลายเดือนก่อน

    Solaris still exists?! 😄

  • @jamesarthurkimbell
    @jamesarthurkimbell 2 หลายเดือนก่อน

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

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +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 2 หลายเดือนก่อน

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

  • @alikhatami6610
    @alikhatami6610 2 หลายเดือนก่อน +4

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

    • @kaiser2261
      @kaiser2261 2 หลายเดือนก่อน +1

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

  • @MrAlanCristhian
    @MrAlanCristhian 2 หลายเดือนก่อน +3

    I want to know more about the new Incremental Garbage Collection

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +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.

    • @Danielm103
      @Danielm103 2 หลายเดือนก่อน +1

      I’m a bit worried about this. I’m writing wrappers for AutoCAD where the objects have an open-forread, open-forwrite, and closed state. As of now, GC is mostly deterministic and I rely on it’s current behavior

  • @JarppaGuru
    @JarppaGuru 2 หลายเดือนก่อน

    dont know whats removed? lol 3.14 coming

  • @dwight4k
    @dwight4k 2 หลายเดือนก่อน +1

    653 or 563?

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +3

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

    • @dwight4k
      @dwight4k 2 หลายเดือนก่อน +2

      @@Carberra No problem. Great video.

  • @lbgstzockt8493
    @lbgstzockt8493 2 หลายเดือนก่อน +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.

  • @codeguy7309
    @codeguy7309 2 หลายเดือนก่อน +32

    now python is slower even faster

  • @ivankramarenko
    @ivankramarenko 2 หลายเดือนก่อน

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

  • @hanyanglee9018
    @hanyanglee9018 2 หลายเดือนก่อน

    the future of python is tython, not multi threaded.

  • @aristonsaizoxic1048
    @aristonsaizoxic1048 2 หลายเดือนก่อน +4

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

    • @matis9783
      @matis9783 2 หลายเดือนก่อน

      Xd

    • @ewerybody
      @ewerybody 2 หลายเดือนก่อน

      what's a pyscript?

    • @yashdeveloper9449
      @yashdeveloper9449 2 หลายเดือนก่อน

      ​@@ewerybodyjavascript but py

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +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: th-cam.com/video/VD2s23JgE7I/w-d-xo.html

    • @MrZmogZ
      @MrZmogZ 2 หลายเดือนก่อน

      There is transcrypt

  • @seansingh4421
    @seansingh4421 2 หลายเดือนก่อน

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

    • @Carberra
      @Carberra  2 หลายเดือนก่อน

      Did it? How so?

    • @seansingh4421
      @seansingh4421 2 หลายเดือนก่อน

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

    • @TedMan55
      @TedMan55 2 หลายเดือนก่อน

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

  • @afterschool2594
    @afterschool2594 2 หลายเดือนก่อน

    Nah, I am waiting for πthon

  • @djtomoy
    @djtomoy 2 หลายเดือนก่อน

    2.7 4 life

    • @yoyonel1808
      @yoyonel1808 2 หลายเดือนก่อน

      😀

    • @danilomenoli
      @danilomenoli 2 หลายเดือนก่อน +2

      Ew brother

  • @pikadroo
    @pikadroo 2 หลายเดือนก่อน

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

  • @ButchCassidyAndSundanceKid
    @ButchCassidyAndSundanceKid 2 หลายเดือนก่อน +4

    Get rid of the GIL !

    • @themartdog
      @themartdog 2 หลายเดือนก่อน

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

    • @Carberra
      @Carberra  2 หลายเดือนก่อน +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  2 หลายเดือนก่อน +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 2 หลายเดือนก่อน +2

      What has Gil ever done to you?

    • @ButchCassidyAndSundanceKid
      @ButchCassidyAndSundanceKid 2 หลายเดือนก่อน +2

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