Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Python 3.10 #1

Open
JackGeraghty opened this issue Nov 23, 2021 · 1 comment
Open

Upgrade to Python 3.10 #1

JackGeraghty opened this issue Nov 23, 2021 · 1 comment

Comments

@JackGeraghty
Copy link
Contributor

Why upgrade to 3.10? Mostly quality of life improvements to python. This update would also encompass features introduced in Python 3.9 like generic type hinting, dictionary merging and updating operators and some string prefix and suffix removal functions.

Python 3.10 then introduces some more quality of life like better error messages, pattern matching (a more powerful switch statement) and type aliasing

Overall I think it should bring features that will improve the code base, make it all more readable and enable some new node functionality.

# Generic Type Hinting
# <= 3.8
my_list: list[str] # error
my_dict: dict[str, int] # error

from typings import List, Dict

my_dict: Dict[str, int] # ok
my_list: List[str] # ok

# > 3.8
my_list: list[str] # ok
my_dict: dict[str, int] # ok

# Dictionary Merging
x = {"key1": "value1 from x", "key2": "value2 from x"}
y = {"key2": "value2 from y", "key3": "value3 from y"}
z = x | y
# z = {'key1': 'value1 from x', 'key2': 'value2 from y', 'key3': 'value3 from y'}
# Patter matching
class Point:
    x: int
    y: int

def location(point):
    match point:
        case Point(x=0, y=0):
            print("Origin is the point's location.")
        case Point(x=0, y=y):
            print(f"Y={y} and the point is on the y-axis.")
        case Point(x=x, y=0):
            print(f"X={x} and the point is on the x-axis.")
        case Point():
            print("The point is located somewhere else on the plane.")
        case _:
            print("Not a point")

# Type Aliasing
StrCache = 'Cache[str]'  # a type alias

# Better error messages
def foo():
    if lel:
        x = 2
  File "<stdin>", line 3
    x = 2
    ^
IndentationError: expected an indented block after 'if' statement in line 2
@JackGeraghty
Copy link
Contributor Author

Forgot to mention that the limiting factor to upgrading is that some required dependencies (llvmlite) hasn't been updated yet and are incompatible with 3.10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant