Rodrigo Girão Serrão 🐍🚀 @mathspp.com · Jan 21

These two typing features look similar... But they're very different. Here's how to use NewType and TypeAlias in Python 👇

1 likes 1 replies

?

Replies

Rodrigo Girão Serrão 🐍🚀 · Jan 21

`TypeAlias` creates a synonym to a complex type with the purpose of simplifying long or cumbersome type signatures: ```py type P = tuple[int, int] def add_points(p1: P, p2: P) -> P: x1, y1 = p1 x2, y2 = p2 return (x1 + x2, y1 + y2) ```