NEW Python 3.11 !!!

Futurescience
40 followers
9 Video Views·Nov 9, 2022
Python 3.11 released yesterday, at least at the time recording and releasing this video.
In case you haven't heard, the latest release of Python is something that the community is
super excited about because it is allegedly faster, about 10 to 60% faster than previous
iterations of the Python version. And you get better error messages when something is wrong
in your code. Those are just a few of the cool new things that we're all chatting about with
the latest release of Python 3.11, but let's dive into the release notes, check out the change log
and kick the tires and see how this thing looks. I'm online at docs.python.org and we're checking
out what's new in Python 3.11. Again, this was released on October 24th, 2022, just this Monday,
and Python 3.11 is between 10 to 60% faster than Python 3.10. Now I'm not going to bore you with
all of the ins and outs and the things that are different, but I think there are some really cool
things that are worth talking about, like TOML. Hey, support for the new markup language. I think
that's what, TOMS? Yeah, yeah, yeah. TOMS, obvious minimal language. That's another config file
structure that I've been using, even as opposed to JSON and YAML. We might be using this for a
future capture the flag challenge development, just to package it all up inside of our environment
and infrastructure. So I'm pretty happy to see that. There are new exception groups. There are
a lot of new typing features. Again, Python is a weekly type language, as in you don't need to
define, oh, this variable is an int or this variable is a float or double or whatever. You
can just kind of let Python figure out what variable and data type you want to be working
with, but it is good to annotate your code with the typing that is recommended. We'll touch on
that in just a moment, but it is worthwhile to note that some legacy standard library modules
have been deprecated. There is a list here that they reference. I don't think there's anything
huge in this list. Maybe some folks will be sad to see CGI go. Crypt, I guess I used that a long
time ago to like generate, I don't know, passwords that might be stored naturally in a center of
shadow. But that again is way, way old and there are better ways to do that now. Telnet lib,
meh, whatever. Maybe you have some odd library that you happen to love in this list, but it's
going away. But what I see everyone raving about is the fact that there are now fine grain error
locations in traceback. So you can see exactly the specific character or portion of your code
to the line in that specific section that caused the error. Like, Oh, getting specifically this
function call or getting specifically this variable that you're trying to index or retrieve
some attribute out of. It'll draw these nice little arrows just surrounding it. So you can
see this is the problem and you need to go fix this portion of the code rather than something
somewhere on that line. This can be super duper helpful within nested functions as they explain
here, even drilling down to the absolute bottom of the trace back where you see the most top level
error here, like indexing just one portion of an already index list or slice or whatever.
And back to the note of type hinting some pretty cool thing. As you annotate specific types that
functions might return or variables that you end up passing to arguments and parameters,
specifically when you have an object or a class and that you have some function internally that
will return an instant of itself, like the object same class, you can return self with a capital S
here to denote this is going to return an instance of that object or excuse me, instance of that
class. Correct. The async IO module is improved with a new task group class that allows an
asynchronous contact manager to hold a group of tasks that will wait for all of them upon exit.
They recommend using this over create task and gather, which is a little surprising to me because
I see that all the time when I have to deal with a synchronous code, which I try to avoid because
it's a complicated and hard for my small, smooth brain. I'm a three head, but Hey, for the smart
people. Cool. You got something better. I am super duper happy to see some improvements to the date
time module. Now they have a little constant for date time UTC or at least an alias. Sorry, not so
much a constant, but being able to actually work with universal time zone and pulling that from
ISO formats, it can now parse more formats than it could before. And I know that I've run into
that wall sometimes in the past, I prefer to have something easily recognize that. And I'm glad date
time is now new and improved. A couple other modules that I think are worthwhile mentioning
the OS module on windows, OS dot random will now use this method internal function rather than the
deprecated rendition. So cool to see that good to see some improvements in our windows world.
I'm digging this path lib one because it looks like now glob and our glob will return only
directories. If the pattern argument that you supplied to glob ends with a path name separator,
like a forward slash and Linux or backslash and windows, the SEP or alt separator for different
subdirectories and folders. This honestly could be kind of a neat capture the flag challenge
in some gimmick, weird abomination idea. I'm thinking on that a little bit. There are tons
and tons of other cool new improvements and features to a lot of these standard library.
And again, I don't mean to bore you with all this. If you wanted to cruise through this,
the link will be in the description to see all the new improvements and changes in Python 3.11.
But again, the coolest thing we get to rave about is dude, Python is faster. We are looking towards
the future, though new things that will be changing in Python 3.12. Once that eventually
releases again, not trying to get ahead of things. We did just get to see the release of 3.11. But
in the future on the horizon, we will see some changes looks like we'll end up removing a couple
of these methods, functions, things that you might be able to do. I tend to see import lib
find loader actually in a lot of code that tries to dynamically load representations and portions
of packages or other units that might just want to load to have cleaner code. Weird to see import
lib getting something kicked to the curb. But hey, I know there's going to be new improvements for
the future. Anyway, that is enough talk. It'd be nice to do a little bit of show and tell. However,
there's not much to really showcase other than hey, it's Python better than ever before. They
got a sweet new logo with version 3.11. And you can go ahead and download this right now. I am
running Windows. So forgive me, I'm just going to go for a regular Windows installer. We can go ahead
and kick this thing off Windows installer 64 bit. Yep, let's roll with it. And let's fire it up.
I'll go ahead and install now. I'll click that checkbox to add Python.exe to my global path.
We'll hit install now and we can get cruising. Now that that is installed and done. I can fire
up a terminal. I'll hit F11 to full screen this and I can run Python. You'll see that I am running
Python 3.11.0, released as of October 24, 2022. And nothing super special within the interpreter.
Hey, I can go ahead and import things. I don't have any syntax highlighting. The command line
instance is just fine as it was. You know, run command, do whatever you want with these libraries.
Again, bear in mind on Windows, OSU Random is now using some sweet internal functions here.
The number of bytes that we want to retrieve, hey, random bytes, super duper cool. Let's build
out a simple script where we can actually go ahead and play with errors. We'll call this a
play errors.py. And in this sublime text window, I'll go ahead and create a variable called please
subscribe. I'll go ahead and actually use some type hinting to say, oh, that could very well
be a string. And we'll just set this to click the button. There we go. If I wanted to simply
go ahead and print, please subscribe. Super boring Python code, but ultimately this should work for
us. I'll hit control B so I can run it within sublime text. Looking good. Now, if I accidentally
had a typo here, maybe I forgot the E at the very end. We'll hit control B to run this. But now you
can see the arrows are indicating this specific variable is not defined. And actually, did you
mean, hey, this variable that you have already defined? We could do something else interesting.
We could say simply, I don't know, subscribers, number of subscribers. I am super original. We'll
set that to zero. We could set please subscribe divided by the number of subscribers. Run that
error one more time and check it out. You've got some squigglies leading up to a carrot denoting
this division sign. Whoa, we're doing some weird unsupported operand for types, dividing strings
and integers. Let me change this to an int and then set this to, what are we at now? 480,000
something. I don't know. Try to run that. Whoa, we've got our division by zero again, keeping in
mind that zero division error. If I run this within the command line, do I have any better output? I
at the moment, but if we end up using PIP or Python, we can go ahead and install anti-gravity.
I don't think that's a module. Let's get something like flask. How about that? That should go ahead
and install for me. And again, we do have nice color, but I believe that's in the Python release
for quite some time. Color in the PIP install is nothing big, nothing new or nothing fancy.
I don't know if you could feel the speed improvements. I don't know the nanoseconds,
milliseconds. If you could tell it as you were typing, does Python feel a little bit peppier,
10 to 60% faster or 1.25 times faster than 3.10. I don't know. Awesome. Great to see the
improvements. Super happy for the release of Python 3.11. Hey, super small, super simple video.
If anything, just an announcement. Wanted to let you know in case you didn't see it, in case you
missed it, new releases out, go ahead and get installed, go play with it, kick the tires and
tune back in to your Python projects. Thanks so much for watching everybody. Hope you enjoyed
this video. I don't know, super small, super simple. Link in the description for the proper
changelogs. Thanks so much for watching everybody. See you in the next video. Please subscribe.
Don't forget. It is the name of the variable for a reason. Click the button and the bell.
The bell actually helps, you know, improve the algorithm and we're cruising on that 500,000 mark.
So please subscribe. I'm going to see you later. Goodbye. See ya.
