What do you think about adding statictyping to Python?

Source: Internet
Author: User
On twiter, pay attention to guidovanrosum. it seems that I have been engaged in statictyping recently. pan. baidu. coms1cFROXS (A recent ppt) blog also suddenly added neopythonic.blogspot.com and followed Guido van rosum on twiter. .
Python seems to have been engaged in static typing recently.
Http://pan.baidu.com/s/1cFROXS (The latest ppt)
Blog also suddenly more http://neopythonic.blogspot.com/ Reply content: not the annotation for linter, which was updated on April 9, May 31, 2016.

if False:    from a import Aclass B:    def compare(self, a: 'A')
According to the official statement, Python will never become static typing. The new syntax is only used to help the IDE check, there is no limit to the actual running, and isinstance and assert can be used to achieve the same effect. It just saves some trouble.

However, for a large number of weak APIs in python (functions are implemented even if the inheritance is not used), hasattr and assert are still used. To put it this way, only 484 of the currently used PEP states how you should do the type annotation, but no PEP mentions how the interpreter performs the type check, because the interpreter does not perform type checks.

The PyCon said that the type check mechanism (not the type hint) should be mentioned to PEP. Of course, it is unknown who will take care of it, how it is implemented, and whether it will be changed. Although py is purely interpreted as a dynamic type language, it won't really bother you with a compilation period to meet the requirements of static type check, however, at least a later version of Py may provide you with a unified type check method, which may be a decorator or a running parameter, but in any case, it is no longer a global assert. (Even a heavy-load decorator ......)

What does this mean? It is easy to write, and you no longer need to set an assert for each parameter to ensure the type is available. Second, although there is no compilation period, it is good to do test. Besides, JIT, pypy indicates that the annotation is useless, because the annotation does not actually play a limiting role, but if there is a unified standard restriction method, at least it is no longer useless, you can see that Pyston (Pyjion is not familiar with) still hopes to have such a type check.

Of course, this type of check won't be as important as Java/C ++, before execution, you can ensure that there are no type errors (in the end, the above language still cannot handle runtime errors such as overflow out of bounds). In the end, there is no compilation period at all. I only wrote a few gadgets on my hand. I don't know how powerful the type check in the process of compiling and translating TS into js, is it possible to configure a type check even when importing a native js write? If so, why cannot py be used? If not, isn't it a reasonable and effective way to encourage communities to transform by introducing standards?

---------- People who have been there long ago must have not read the ppt ......

----------
What people say is not a 484 weak hint, but a real type check based on the hint, a restriction during runtime, and derivation during non-runtime, it's not the one that uses lint.

The type sig is not the interpreter-level static type.

It seems that a new pep has been submitted (THE pep index does not seem to be found ...). But put it in THE pep, it's not necessarily the final say of anchor ......

-----------
We can see that the milestone is good, and the faster check mechanism mentioned later is worth looking forward to. Although cpython still needs to pack a decoration device to implement the check.

The type check of TS is similar to that of TS during compilation. It does not include non-TS. If the Static type feature of Py can be incorporated into CPython one day, at least JIT can be provided with sufficient convenience.

The only problem is that most Py modules have not performed type checks ......

------
Xi Da Pu Ben! Nice to hear!

However, Python cannot control the abnormal PSF like a god. When can it be used.

After the static type is completed, we can finally consider incorporating JIT into the official CPython? Of course, I have been familiar with swift recently and can't do without static types. When I pay attention to mypy, I feel that I am going wrong. The type derivation should not be compatible with the interpreter, otherwise, the hinting syntax is very strange, and some problems may occur due to the interpreter.

I think we should use typescript to pre-compile and generate non-type code. Since the official team also thinks that we should not add type restrictions during runtime, in this case, typing does not need to be syntactically compatible. Of course, I am a asset!
Recently, I have transplanted a python-written MYO open-source protocol to c ++, And I want *#&.
In addition, the pack unpack of struct is really easy to use and conscientious. It shows the type to a large extent, but porting it to cpp depends on humans.
Finally, I would like to thank std: function, std: bind, brace-initialization, typedef, using, auto, shared_ptr for some minor work, only 1000 rows of python are migrated to c ++. Those trendy languages are just temporarily naked. When programmers get their hands, they will finally wear their clothes to their favorite ones, and the code will be 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.