40 ms·
A new statement, wow! I wonder if the price is worth the benefit. The new syntax for generic functions and classes is great. Brings it in line with other langu
by diarrhea 3y ago
A new statement, wow! I wonder if the price is worth the benefit.
The new syntax for generic functions and classes is great. Brings it in line with other languages.
- gnulinux 3y agoJust to be clear, because it's buried everywhere and it's only in the original PEP page, these are examples of the new statement: # A non-generic type alias type IntOrStr = int | str # A generic type alias type ListOrSet[T] = list[T] | set[T] # A type alias that includes a forward reference type AnimalOrVegetable = Animal | "Vegetable" # A generic self-referential type alias type RecursiveList[T] = T | list[RecursiveList[T]]
- notatallshaw 3y agoIndeed, there was some controversy about the implementation cost: https://discuss.python.org/t/please-consider-delaying-or-even-rejecting-pep-695/26408 https://discuss.python.org/t/please-consider-delaying-or-eve...
- The_Colonel 3y agoI think implementation cost is a smaller worry, the main problem is the introduction of complexity for a relatively minor gain.
- notatallshaw 3y agoThat's a very under specified criticism, what type of complexity do you think it has introduced and how do you quantify "minor gain"? Some people clearly think it is an appropriate complexity to solve for the gain it gives, hence the detailed proposal and long discussions that have already taken place: * https://mail.python.org/archives/list/typing-sig@python.org/thread/BB2BGYJY2YG5IWESKGTAPUQL3N27ZKVW/ https://mail.python.org/archives/list/typing-sig@python.org/... * https://discuss.python.org/t/pep-695-type-parameter-syntax/21646 https://discuss.python.org/t/pep-695-type-parameter-syntax/2...
- The_Colonel 3y agoI just read the link you posted and people there seem to be worried about the introduced complexity.