December 21, 2021 Yen Lily

Python 3.10 ships new awesome features

Today, Python is one of the most popular programming languages for many reasons. It is very versatile, easy to learn and always has improvements.

On October 4, 2021, the Python Software Foundation (PSF) released Python 3.10. In this new version, the PSF added unique and valuable features, while also removing some old features. Let’s find out some newest features and add-ons in this version.

1. Better Error Tracking

If you use Python every day to write code and teach coding, it’s very frustrating to get a syntax error. Although syntax errors are easy to fix once you have a grasp on Python and programming, sometimes we need error messages that help us locate the error more efficiently and save time on debugging.

In Python 3.10, this is all much easier with better error messages and precise line numbers for debugging. Let’s take a look at the example here, where we have a dictionary and a function. However, in this code, we forgot to close the dictionary.

some_dict = {1: "jack", 2: "john", 3: "james" ,
a_results = a_useful_function()

In previous versions of Python, the error message for this would look like this:

File "amazing_code.py", line 3
   a_results = a_useful_function()

             ^

SyntaxError: invalid syntax

With the new error messages and line numbering improvement, the error message will have more complete information, like the exact type of error and its precise line number.

File "amazing_code.py", line 1
   expected = {1: "jack", 2: "john", 3: "james" ,

                                 ^

SyntaxError: '{' was never closed

This new feature will make debugging much faster and decrease frustration for people just starting to learn Python.

2. Structural Pattern Matching

Old version of Python needs you to go through the long if, elif, elif,…., else statement, and sometimes you just wish it had the switch statement like other programming languages like C++. Don’t worry, in this new version, they add structural pattern matching otherwise known as the switch, case statement which has the following syntax:

match subject:
   case <patt1>:
       <act1>
   case <patt2>:
       <act2>
   case <patt3>:
       <act3>
   case _:
       <action_default>

3. New Type Union Operator

Although Python is a dynamic programming language, there are ways to make some portions of it static (e.g. You’re writing a function and the attribute type is significant for the commutations inside your function). In previous versions, you could specify the type of an attribute such as:

def func(num: int) -> int:
return num + 5

But, if you wanted to accept two types, then you would need to use the union keyword.

def func(num: Union[int, float]) -> Union[int, float]:
   return num + 5

In the new version of Python, you can choose between two types, using the | operator instead of union for a more straightforward type decision.

def func(num: int | float) -> int | float:
   return num + 5

4. Stricter Zipping

Python has a function called zip(), a built-in function that allows you to combine and iterate over elements from several sequences. In old versions, you could’ve used zip with sequences of different lengths but Python 3.10 introduced a new parameter, strict was, to check if all iterables passed to the zip function are of the same length.

5. Automatic Text Encoding

When a programmer is troubleshooting errors, we often hear “it works on my machine!”, but it’s not the case of other machine. There are many reasons, like text encoding, why a code will work on one machine but not the other.

In previous versions of Python, if you don’t explicitly state an encoding type, the preferred local encoding may cause the code to fail on other machines. In Python 3.10, a warning activates to inform the user when (or if) they open a text file without a specific encoding type.

6. Asynchronous Iteration

Asynchronous programming is a powerful and advanced programming paradigm that’s been a part of Python since version 3.5. In Python 3.10, there are two new asynchronous built-in functions, aiter() and anext(), to make your code even more readable.

With every new release of Python, the PSF adds incredible new features that make the language more efficient to write in and more accessible to learn. If you want to read more about other changes in Python 3.10.

iRender - The best GPU cloud for Python

At iRender, we provide multiple GPUs for renting with state-of-the-art RTX3090. Our remote machines are Optimized for Scientific Computing, Machine Learning, Deep Learning.

We support not only Python, but also all AI IDEs & Libraries such as: TensorFlow, Jupyter, Anaconda, MXNet, PyTorch, Keras, CNTK, Caffe and so on.

This is our packages tailored for AI/ Deep Learning:

Plus, at iRender, we provide you more support than just those config.

NVLink available for better performance

If 24GB VRam is not enough for your project, we always have NVLink to help you access more than that. You can access this article to know how to set up NVLink on our machine.

Free and convenient transferring tool

iRender offers a powerful and free file transfer tool: Gpuhub Sync. With fast file transfer speed, large data capacity, and completely free. You can transfer all the necessary data into our Gpuhub Sync tool at any time without connecting to the server. The data will be automatically synchronized in the Z drive inside the server, ready for you to use.

Flexible price

Besides hourly rental, you can always save from 10% to 20% with our Fixed Rental feature. For those who’s in need of server more than a day, or have extremely large project, we advise to choose daily/ weekly/monthly rental package. The discount is attractive (up to 10% for daily packages, 20% on weekly and monthly packages), and you don’t have to worry about over-charging if you forget to shutdown the server.

Real human 24/7 support service

Users can access to our web-based online platform and using multiple nodes to render at the same time. Hence, with us, it does not matter where you are present – as long as you are connected to the internet, you can access and enjoy the 24/7 rendering services that we provide, and if you meet any issue, our real human 24/7 support team is always ready to support you.

 

With these advantages and no hidden cost when using our machine, we believe it’s worth for trying your project. Register an account today to experience our service. Or contact us via WhatsApp: (+84) 916806116 for advice and support.

 

Thank you & Happy Training!

Source: builtin.com

Related Posts

The latest creative news from Cloud Computing for AI,

, , , , , , , , , , , , ,

Yen Lily

Hi everyone. Being a Customer Support from iRender, I always hope to share and learn new things with 3D artists, data scientists from all over the world.
Contact

INTEGRATIONS

Autodesk Maya
Autodesk 3DS Max
Blender
Cinema 4D
Houdini
Daz Studio
Maxwell
Nvidia Iray
Lumion
KeyShot
Unreal Engine
Twinmotion
Redshift
Octane
And many more…

iRENDER TEAM

MONDAY – SUNDAY
Hotline: (+84) 912-785-500
Skype: iRender Support
Email: [email protected]
Address 1: 68 Circular Road #02-01, 049422, Singapore.
Address 2: No.22 Thanh Cong Street, Hanoi, Vietnam.

Contact