python: NewType vs aliases (intermediate) anthony explains #368

preview_player
Показать описание
today is another python typing video -- NewType! I talk about how you can utilize NewType and how it differs from aliases

==========

I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
Рекомендации по теме
Комментарии
Автор

I'll take up aliases anytime of the day... do we have any practical use cases for the NewType in production?

akshaymestry
Автор

I don't think that I like that the following is True. If you want that to be false, what's the best way to do that? Make a @dataclass with a single field like "value", take the performance hit, and write the forwarding functions that you want to have available?
A = NewType("A", int)
B = NewType("B", int)
print(A(1) == B(1))

michaeldarling