Unfortunately, I can tell you from experience that out in the real world, at fortune 500 companies, there are millions of lines of untyped Python doing critical work while being full of subtle type errors which should be compile time errors but will rear their heads as runtime errors when it's least expected.
It's def not as pervasive yet as Typescript.
Your statements are incongruent with the reality of production.
Even so where I worked is only part of the equation. You can look up which companies use python types in a google search.
Let me add more nuance, companies that use python as glue code as in scripting languages don't use types. This makes sense as python is considered not as important as the main language.
For companies that are primarily based on python... the majority use types. The ones that don't are actively migrating. This includes faang and subsidiaries. In fact type checkers for python are likely to be built by faang or companies close to that tier.
Even at companies that do use type hints, there’ll be tons of legacy code that won’t (and probably tons of new code as well if we’re being realistic).
It’s like saying every company uses bash scripts. It’s not really indicative of the prevalence in actual code bases in production use other than saying it may be used somewhere within the company.
Between this and your other comments, you’re making very widespread comments that can’t logically apply to everything and nor do they in my experience.
The first part is true, I agree with that assessment and I never made a contrary claim. Companies are migrating.
The second part in parenthesis, is less common, I don't agree that it's a generality among companies that have python as a primary language.
>It’s like saying every company uses bash scripts. It’s not really indicative of the prevalence in actual code bases in production use other than saying it may be used somewhere within the company.
I don't even know what you're getting at with this example. Tons of companies use python "somehwhere" within the company. I'm sure in those cases it's often not typed.
But for companies or teams that use python as a primary it's typically typed or in the process of getting migrated to be typed. That is the nuance I added to my claim.
>Between this and your other comments, you’re making very widespread comments that can’t logically apply to everything and nor do they in my experience.
Except you made statements that are factually wrong. I literally ran mypy on some code and your statements were categorically incorrect from your other comment. Usually these debates are anecdotal so logic doesn't apply as it's just fuzzy opinions regarding social aspects of society. But that's not the case here. You made factually incorrect statements and that has bearing on the correctness of your anecdotal statements too.
Regarding ADTs: do type checkers ensure totality (all cases covered) when pattern matching?
(I’m not casting aspersions here. It is what it is, you know?)
Agree with mypy being slow. As for the culture it's largely moving in the right direction and it's at a point where you're more likely to find a python shop to be using typing than not. Of course for scripting I think people may not be so readily adopting types.
>Regarding ADTs: do type checkers ensure totality (all cases covered) when pattern matching?
Yes it does.
Cast your initial presumption aside. This was a huge surprise to me too. Everybody loves typescript but basic usage of types in typescript is actually less powerful because it doesn't support this.
You have to use it in a specific way though.
https://tech.preferred.jp/en/blog/python-exhaustive-union-ma...
Type checking is analysis post facto and doesn’t account for dynamicism of classes.
The very ability to self modify an instance at any time or use __getattr__ makes it incredibly dynamic.
It also doesn’t account for every dependency having accurate type hints or any at all.
My mistake for not being clear. Obviously the python interpreter itself does not do any type checks.
It's sort if like how modern development with javascript is used with an external compiler of another language (typescript) that compiles a typed language into one without types.
An object can conform to a type in name only, but that’s not enough to tell you what methods or attributes exist on it at any given time.
In practice, your rebuttal almost never occurs. I believe these type checkers can detect monkey patching and trigger a type error or warning.
There are tons of libraries in many companies that use dynamic attribute lookups for efficiency reasons, when adapting to different data sources and the like. Or pass through lookups on nested objects. Or they’re dynamically looked up on bound libraries from other languages and frameworks.
And these type checkers cannot detect it. Python’s dictionary access is not guarded by the type checkers and neither is __getattr__.
If you’re making such wide sweeping statements you need to be more familiar with the subject matter.
Of course it still is.
The type hints have no runtime semantics whatsoever.
The actual type-checking still happens at runtime in Python, and is not related to any static checks. Out of the perspective of Python's interpreter the type hints don't even exist. They're like comments…
Static type checking is not part of Python!
> Python also has ADTs which match it in power to rust.
All Turing-complete languages match each other in power…
Besides that:
Python doesn't have a static type system in the first place, so it can't compete with Rust in this regard. That's not even the same game.
I clarified my meaning in another comment. You're right, I meant to SAY modern development involves type checking with python. But not with the interpreter. My mistake for not being clear.
>All Turing-complete languages match each other in power…
I obviously mean type checking. Additionally what you're saying isn't even true. Not all turing complete languages match in power or capability.
>Python doesn't have a static type system in the first place, so it can't compete with Rust in this regard. That's not even the same game.
Modern python development is done in conjunction with a type checker. Sort of like how modern javascript development is done with typescript. That levels up the game to where python is roughly in the same class as rust when it comes to type correctness.
Depending on the type checker python matches the power of rust, roughly. There are differences, but for ADTs they are pretty similar in capability.