On Tue, 21 Apr 2015 22:47:23 +1000 Steven D'Aprano <st...@pearwood.info> wrote: > > Ironically, type hinting will *reduce* the need for intrusive, > anti-duck-testing explicit calls to isinstance() at runtime:
It won't, since as you pointed out yourself, type checks are purely optional and entirely separate from compilation and runtime evaluation. > Why bother making that expensive isinstance call every single time the > function is called, if the type checker can prove that x is always a > float? Because the user might not run the type checker, obviously. To quote you: """When we say that type checking is optional, we mean it.""" You can't at the same time point out that type checking has no power or control over runtime behaviour, and then claim that type checking makes runtime behaviour (for example, ability to accept or reject certain types) saner. It is a trivial contradiction. (and because of the former property, type hints can be entirely wrong - for example incomplete, or too strict, or too lax - without anyone noticing as long as they are self-consistent, since runtime behaviour is unaffected by them) Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com