Type hinting of Python is just a toy ?

lorenzo.gatti at gmail.com lorenzo.gatti at gmail.com
Fri Jan 4 11:47:29 EST 2019


On Friday, January 4, 2019 at 9:05:11 AM UTC+1, iam... at icloud.com wrote:
> I read that pep 484 type hinting of python has no effect of performance, then what’s the purpose of it? Just a toy ?
Having no effect on performance is a good thing; Python is already slowish, additional runtime type checking would be a problem. 
The purpose of type hinting is helping tools, for example ones that look for type errors in source code (e.g. a function parameter is supposed to be a string, but an integer is being passed).
> 
> Python is an old programming language, but not better than other programming languages, then what are you all dong for so many times ? 
Being nice in general, and not too aggressive with trolls in particular, is also a good thing.
> 
> Pep484 is too complex. Typle should not a seperate type, in fact it should be just a class. Like this in other programming language
> Python: Tuple(id: int, name: string, age: int)
> Other: class someClass {
> 	public int id;
> 	public string name;
> 	public int age;
> }
But tuple (not Tuple) is already is a class. Are you missing the difference between declaring a type and invoking a constructor? Try to work out complete examples.
> Design of OOP of python is too bad, so it treat Tuple as a seperate type.
If you mean that defining classes could be replaced by uniformly using tuples, it is not the case because classes can have a lot of significant behaviour, including encapsulation.
If you mean that the specific tuple class shouldn't exist and all classes should be in some way like tuple, it is not the case because many classes have to behave differently and above that tuple has special syntax support. It's about as special as the dict class and the list class, and clearly different.
> Why looks different than others? afraid of cannot been watched by others?
Like most programming languages, Python was deliberately designed to be different from existing programming languages in order to make an experiment (which could be summarized as interpreted, with a lot of convenient syntax in order to be brief and readable, strictly object oriented, strongly but dynamically typed) and to gain adoption (by offering an advantage to users who wouldn't bother trying a language that is only marginally different from existing ones). 
By all means, use other programming languages if you think they are better, but don't expect Python to change in radical ways.




More information about the Python-list mailing list