New Features In Python 3.10 You Should Know

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and welcome back to another video python 3.10 should be released today so in this video i go over all the important changes to bring you up to date the new version brings some great new features and improvements so let's go over them structural pattern matching lets you match variables against a set of different possible values like the switch case in other languages you can use it with the match statement and case statements of patterns with associated actions here's a simple example notice also how you can combine several literals in a single pattern using the pipe operator but you can match it not only against a simple value but also match against patterns of values for example a tuple or a class object with a certain property set to a specific value pattern matching is certainly the most interesting new feature and i can see it being used in many different scenarios now you can use enclosing parentheses around context managers when you use the with statement this allows formatting a long collection of context managers in multiple lines an optional strict boolean keyword was added to the sip method to ensure all iterables have the same length zip creates one single iterator that aggregates elements from multiple iterables the default behavior is simply to stop when the end of the shorter iterable is reached like in this example it just combined the first two elements and discarded the third name with the new parameter strict equals true this will now raise a value error if the iterables do not have the same length this is another improvement i find really helpful many of the error messages have been improved not only delivering more precise information about the error but also more precise information about where the error actually occurs for example in this code with a missing parentheses the old error was just an invalid syntax message not even with the correct line number and now we can see the correct line number the correct position and the good error description here's another example with an indentation error again we see the exact line and position and an accurate error message i like these improvements a lot and i think this could be especially helpful for beginners that previously oftentimes only got confused by the error message the typing module provides runtime support for tie pins and got a few additions in python 3.10 a new type union operator was introduced which enables the syntax x pipe y this provides a cleaner way of expressing either type x or type y instead of using typing.union additionally this new syntax is also accepted as the second argument to is instance and is subclass now the typing module has a special value type alias which lets you declare type aliases more explicitly this is useful for type checkers to distinguish between type aliases and ordinary assignments in addition to new options to improve the information provided to static type checkers have been provided by paramspec and concatenate i will link an article below where you find more details about these types python now requires openssl 111 or newer older versions are no longer supported this affects the hash lib hmac and ssl module and modernizes one of c python's key dependencies also the entire disk utils package is deprecated and will be removed in python 3.12 no new modules are added but a lot of modules have been improved here's a brief overview of most of the improved ones and again you can find the full list in the article i put below the video multiple optimizations were implemented to make python faster the most important ones are the constructors for string bytes and byte array are now faster around 30 to 40 percent for small objects and the run pi module now imports fewer modules this means the command python 3-m module name has a 1.4 times faster startup time on average on linux python 3-i-m module name import 69 modules on python 3.9 and now only imports 51 modules on python 3.10 that's 18 less modules in the new version python 3.10 brings many great new features optimizations and improvements the most interesting one is certainly the pattern matching feature and i also like the improved error messages a lot so let me know in the comments which new feature you like the most and if you plan to upgrade to the new version anytime soon and then here's another video that might be interesting to you and i hope to see you next time bye
Info
Channel: Python Engineer
Views: 5,369
Rating: 4.954802 out of 5
Keywords: Python
Id: brq_Nvu2iDc
Channel Id: undefined
Length: 5min 9sec (309 seconds)
Published: Mon Oct 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.