How do I see the addition of the static typing in python?

Source: Internet
Author: User
Twiter on the Python father (Guido van Rossum Of.
Python dad seems to have been working on the static typing lately.
/ http Pan.baidu.com/s/1cfroxs (A recent PPT)
There was a lot more on the blog. / http neopythonic.blogspot.com /

Reply content:

Not for Linter, annotation? May 31, 2016 update, Guido method for resolving circular references
if False:    from a import Aclass B:    def compare(self, a: 'A')
According to the official, Python will never become static typing, now the new syntax is just to help the IDE to check, there is no limit to the actual operation of the same effect can be achieved with isinstance and assert. It's just a matter of saving something.

However, for Python a large bunch of weak interfaces (not using inheritance instead of implementing the interface), there is no OVA, or use hasattr and assert. Let's just say that only 484 of THE PEP currently in use say how you do type labeling, but none of THE PEP mentions how the interpreter will do type checking because the interpreter is simply not doing type checking.

Python dad toss for a long time mypy and this pycon said to the type check mechanism (not type hint) mention pep go. Of course, after the inclusion of WHO to control, how to achieve, will not change, is not yet known. Although PY is purely interpreted as a dynamic type language, it will not give you a compilation period to satisfy the requirements of static type checking, but at least one later version of the Py may give you a truly uniform type checking method, possibly an adorner, possibly a running parameter, but no matter what, it is no longer a universal assert. (or even a heavy-duty decorator ...). )

What's the point? It is convenient to write, it is no longer necessary for you to each parameter to assert to ensure that the type is available; second, although there is no compile period, but do test is good; In addition there are jit,pypy that labeling is not used, because the labeling does not really play a limiting role, but if there is a unified standard limit method, At least it is no longer the use of eggs, you can see Pyston (pyjion not quite understand) or hope to have such a type of inspection.

Of course, this type of check will not be as worthy as java/c/c++, can guarantee you no type error before execution (in the end, the above language can not give you a run-time error such as overflow), after all, there is no compile period. I ts with a few, only a few handwriting on a few gadgets, I do not know your TS in the compiler to compile the type of JS process is strong to what extent, is not even import a native JS write the thing it can also be used to match the type check, if you can, why can't py? If not, is it not a reasonable and effective way to raise standards to encourage community transformation?

—————————— said someone who had already had a look at the PPT.

——————————
What they are talking about is not 484 weak hint, but rather a real type check on the basis of hint, restrictions at runtime, and derivation at non-runtime, not the thing that takes lint.

They're not talking about the type sig, but the static type of the interpreter level, yes, that's what you're saying about the typescript type check mechanism.

Seems to have submitted a new PEP (PEP Index doesn't seem to be found ...). )。 But in THE PEP, it doesn't have to be the Python dad.

———————————
You can see the milestone is good, after the mention of faster inspection mechanisms are also worth looking forward to, although the current use of CPython still need to pack a decorator and so on to achieve the inspection.

TS type checking is at compile time, similarly intuitive ts section, not bird non-TS part; If the static type attribute of the PY can be merged with CPython from the interpreter's point of view, it will be able to provide the JIT with enough convenience at least.

The only problem left, in fact, most of the PY module has not done type check ...

——————
Hi, Big Ben! Loved!

However, the Python father can not control the same as the abnormal PSF, when to use that only days to know.

After the static type, we can finally consider the JIT into the official raise CPython? Of course, recently written accustomed to Swift, has been inseparable from the static type of attention mypy when the wrong way, the type deduction should not go to the Interpreter compatible road, otherwise make hinting grammar is very strange, and use the time will also be due to the reason of the interpreter some problems.

I think it's time to go typescript like that. precompilation produces untyped code, and since the authorities do not think that you should add type restrictions at runtime, then typing does not have to consider grammatical compatibility. I am of course an asset!
Recently in porting a Python write Myo Open Source Protocol to C + +, the type of chaos inside I want to *#&.
Well, the unpack of the struct's pack really works, and the true conscience, to a large extent, explains the type, but the transplant to CPP still depends on human flesh.
Finally, thanks to Std::function,std::bind,brace-initialization, Typedef,using,auto,shared_ptr did some tiny work, 1000 lines of Python ported to C + + Only 1500 rows. Those fashionable language is only temporarily naked, wait for the programmer to seduce hand, finally will take off the clothes to wear a piece back to loved, code better read ...
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.