
On Fri, Jul 8, 2016 at 7:17 PM, Ma Lin <animalize81@hotmail.com> wrote:
I see, Chris' decorator is amazing, I didn't think that way.
That's one of the beauties of Python's model of "everything's an object". Functions can be manipulated (usually in broadly the same way as my example: creating a wrapper function that does stuff before and/or after calling the original), and you can basically do anything you like with the attributes. It's SO handy, in so many places! That said, though, you *can* go too far with that. I discovered recently that Ruby lacks a lot of fairly important features... which are monkey-patched in by Rails. So a Ruby on Rails application has a lot more functionality, even on core types (because you can add methods to the string type by monkey-patching), than a non-Rails Ruby app. There are some things that definitely do need interpreter support, which is why we're now seeing async and await becoming keywords.
I mean add an runtime option, not a build option, it can be only enabled in development/debugging: python -tc a.py Without the option, the interpreter just ignores Type Hints: python a.py
Right, but this means that the code to call a function has to check "was the --tc option specified?" before actually calling the function. Even though the full type checks aren't done, this check has a nonzero cost; and since calling functions happens rather a lot in Python programs (remember, lots of things implicitly become function or method calls), it would add up. Everyone's code would be slowed down slightly to support the occasional case where you want the checking.
Anyway, I just throw an idea to here. Greet to all of you for bring Python to me.
Keep on throwing ideas this way! Ideas are great. Well-thought-out ideas make for interesting discussions, even if they don't get implemented. Often the answer ends up being "here's a way to do this with the current version", but it doesn't carry with it a tag of "and you're an idiot for even suggesting it". We like ideas here - otherwise we wouldn't subscribe to this list :) ChrisA