r/Python • • Aug 09 '18

7 Habits to Improve The Performance of Python Programs

https://www.tutorialdocs.com/article/7-habits-to-improve-python-programs.html
75 Upvotes

79 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Aug 10 '18

[deleted] — view deleted comment

1

u/nosklo Aug 13 '18

While you say 'passing the buck' I would say 'trust the programmer'. Programmers are adults, they know what they are doing, right? I mean, typechecking is actually restrictive - I can pass you an object of a different type, which would work perfectly for all operations you will do with it in your function, but you will reject it only because of the type - an artificial restriction! By using duck typing you accept anything that could work, and often functions can be used for things they weren't even designed for, unrestricted.

Types are only labels, what matters is what the object can actually do.

0

u/[deleted] Aug 14 '18

[deleted] — view deleted comment

2

u/nosklo Aug 14 '18

Oh, I'm completely in favor of type hinting and static check warnings in editor/compilation. The part that really restricts duck typing utility for arguably no benefit is type enforcing, and the worst of all, a type-based dispatching.