What's new in Python 3.13?

  Рет қаралды 76,070

Carberra

Carberra

Күн бұрын

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 Ай бұрын
If you're looking for more juicy details about 3.13, including the GIL-less Python builds, check out my first look video! kzfaq.info/get/bejne/m5p4gqamr8zGd40.html Thanks for stopping by!
@Its2Reel4U
@Its2Reel4U Ай бұрын
Will version 3.14 run under the name Pi-thon?
@Carberra
@Carberra Ай бұрын
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 Ай бұрын
It will be Py-π
@Emayeah
@Emayeah Ай бұрын
​@@sujalgarewal2685 nah more like π-thon
@atommax_1676
@atommax_1676 Ай бұрын
Sounds like russian pronunciation
@DennisJ42
@DennisJ42 Ай бұрын
Hah. I like it. (The pun I mean)
@pythonwithjames
@pythonwithjames Ай бұрын
Nice one for this! Loved the work on Improved error messages.
@Carberra
@Carberra Ай бұрын
Yeah, lot of nice quality of life updates in errors for sure!
@carlosmspk
@carlosmspk Ай бұрын
As someone who likes to split packages into a lot of files, the cyclical import update is amazing.
@Carberra
@Carberra Ай бұрын
Cyclical import update?
@carlosmspk
@carlosmspk Ай бұрын
@@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 Ай бұрын
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 😔
@Anonymous-6598
@Anonymous-6598 Ай бұрын
Finally support for IOS and Android
@vinylSummer
@vinylSummer Ай бұрын
I wonder how android apps like Pydroid work 🤔
@Anonymous-6598
@Anonymous-6598 Ай бұрын
@@vinylSummer, same question
@vinylSummer
@vinylSummer Ай бұрын
@@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 Ай бұрын
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 Ай бұрын
​@@vinylSummer I think it's because Android is just a Linux distribution on which Python can be installed.
@mihailyanchev1905
@mihailyanchev1905 Ай бұрын
Thanks for the useful info 🙏🏼
@c4llv07e
@c4llv07e Ай бұрын
XDG base directory support is my favourite one.
@Lizardboythelazy
@Lizardboythelazy Ай бұрын
Where is this? I don't see a mention of it in the release notes.
@WhiteDoppler
@WhiteDoppler Ай бұрын
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 Ай бұрын
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!
@kokop1107
@kokop1107 Ай бұрын
Ios being added BEFORE Android? Now that is funny to me lmao
@tswdev
@tswdev Ай бұрын
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 Ай бұрын
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 Ай бұрын
The only feature after security patches in upcoming python versions is backwards compatibility, which seems to be missing since... always...
@rkdeshdeepak4131
@rkdeshdeepak4131 Ай бұрын
On android , it already compiles on termux.
@MasterSergius
@MasterSergius Ай бұрын
Wait, we can't migrate to 3.12 because of dependencies and now you present 3.13?
@jamesarthurkimbell
@jamesarthurkimbell Ай бұрын
The TypeIs/TypeGuard stuff feels like it should be a part of pattern matching
@Carberra
@Carberra Ай бұрын
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 Ай бұрын
@@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
@AsgerJon
@AsgerJon Ай бұрын
lmao, how can the jit provide such a small improvement? I recall numba being like orders of magnitude faster.
@betterinbooks
@betterinbooks Ай бұрын
I also would like an explanation on this.
@ilikeshiba
@ilikeshiba Ай бұрын
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 Ай бұрын
@@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 Ай бұрын
@@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 Ай бұрын
@@AsgerJon???? They explained exactly why in the comment you’re replying to.
@unvergebeneid
@unvergebeneid Ай бұрын
Solaris still exists?! 😄
@guilherme5094
@guilherme5094 Ай бұрын
👍
@MrAlanCristhian
@MrAlanCristhian Ай бұрын
I want to know more about the new Incremental Garbage Collection
@Carberra
@Carberra Ай бұрын
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 Ай бұрын
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
@alikhatami6610
@alikhatami6610 Ай бұрын
I didn't understand a thing! Am I that bad of a programmer ?
@kaiser2261
@kaiser2261 Ай бұрын
He went kind of fast but if you understood literally nothing I’d recommend reading one of the O Reilly Python textbooks.
@codeguy7309
@codeguy7309 Ай бұрын
now python is slower even faster
@jordannewberry9561
@jordannewberry9561 Ай бұрын
🐍💨
@JarppaGuru
@JarppaGuru Ай бұрын
dont know whats removed? lol 3.14 coming
@lbgstzockt8493
@lbgstzockt8493 Ай бұрын
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 Ай бұрын
wthell 2k.... may be in 3k it will good(not)
@dwight4k
@dwight4k Ай бұрын
653 or 563?
@Carberra
@Carberra Ай бұрын
It is 563, sorry. I've watched this so many times and missed that! Thanks for pointing that out.
@dwight4k
@dwight4k Ай бұрын
@@Carberra No problem. Great video.
@aristonsaizoxic1048
@aristonsaizoxic1048 Ай бұрын
I wish pyscript would become mainstream.....i don't want to learn another language for front end.
@matis9783
@matis9783 Ай бұрын
Xd
@ewerybody
@ewerybody Ай бұрын
what's a pyscript?
@yashdeveloper9449
@yashdeveloper9449 Ай бұрын
​@@ewerybodyjavascript but py
@Carberra
@Carberra Ай бұрын
I'm plugging myself a lot in the comments today apparently, but I made a video on PyScript if you want to know more: kzfaq.info/get/bejne/jKpippVkr82pZ30.html
@MrZmogZ
@MrZmogZ Ай бұрын
There is transcrypt
@seansingh4421
@seansingh4421 Ай бұрын
Ha Good luck ever running it properly now since the 24.04 LTS fckin broke pip.
@Carberra
@Carberra Ай бұрын
Did it? How so?
@seansingh4421
@seansingh4421 Ай бұрын
@@Carberra pip install soandso used to work perfectly. Now its returns env and permission error for everything, on a local admin account 😑😑
@TedMan55
@TedMan55 Ай бұрын
@@seansingh4421curious to hear more about this, i just built a server running 24.04 and curious to hear how it went
@hanyanglee9018
@hanyanglee9018 Ай бұрын
the future of python is tython, not multi threaded.
@afterschool2594
@afterschool2594 Ай бұрын
Nah, I am waiting for πthon
@djtomoy
@djtomoy Ай бұрын
2.7 4 life
@yoyonel1808
@yoyonel1808 Ай бұрын
😀
@danilomenoli
@danilomenoli Ай бұрын
Ew brother
@pikadroo
@pikadroo Ай бұрын
Oh are you gonna tell us how all our code will break. Get off my feed!
@ButchCassidyAndSundanceKid
@ButchCassidyAndSundanceKid Ай бұрын
Get rid of the GIL !
@themartdog
@themartdog Ай бұрын
Isn't there a GIL-less build as of 3.12?
@Carberra
@Carberra Ай бұрын
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 Ай бұрын
@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 Ай бұрын
What has Gil ever done to you?
@ButchCassidyAndSundanceKid
@ButchCassidyAndSundanceKid Ай бұрын
@@jonragnarsson You should rephrase what has GIL hasn't ever done to you.
Pydantic is OP, here's why
18:10
Carberra
Рет қаралды 3,1 М.
Tom & Jerry !! 😂😂
00:59
Tibo InShape
Рет қаралды 59 МЛН
Haha😂 Power💪 #trending #funny #viral #shorts
00:18
Reaction Station TV
Рет қаралды 15 МЛН
Super gymnastics 😍🫣
00:15
Lexa_Merin
Рет қаралды 108 МЛН
5 Good Python Habits
17:35
Indently
Рет қаралды 402 М.
Python 3.12 release: The BIGGEST in 15 years
8:05
Carberra
Рет қаралды 48 М.
What to expect in Python 3.13
4:48
Carberra
Рет қаралды 10 М.
How To Create Decorator Functions In Python
4:59
Taylor's Software Solutions
Рет қаралды 3,4 М.
python 3.12 was ALMOST javascript
9:32
anthonywritescode
Рет қаралды 56 М.
The mathematically impossible ball that shouldn’t exist.
19:29
Stand-up Maths
Рет қаралды 315 М.
You Are WRONG About 0 Based Indexing
25:02
ThePrimeTime
Рет қаралды 246 М.
Best OS for programming? Mac vs Windows vs Linux debate settled
8:41
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 188 М.
It's time... for PYTHON 3.11!
8:10
mCoding
Рет қаралды 151 М.