Compiling Typed Python
bernsteinbear.com
bernsteinbear.com
class C(int):
def __add__(self, other):
return "no" # sigh
-> class C(int):
def __add__(self, other: int) -> str:
return "no" # sigh
Proper type annotations and using strict mypy type checking will throw an error. test.py:2: error: Return type "str" of "__add__" incompatible with return type "int" in supertype "int" [override]
This is again brought up later in the article.I also thought it was odd to diverge into attempts to compile (against?) non-typed code. That seems at odds with the premise of the article.
This is still a really good article. Just a little meandering.
EDIT: Also, the point is that even if it's well-typed, it can still go and execute arbitrary code. So you can't just specialize the callee.
EDIT: Pushed and thanked you in the commit.
All Python code is always typed; it just might not be annotated. Even then, static analysis tools like mypy are pretty good at inferring types based on the code.
In which case, they actually have, on multiple occasions, including currently Microsoft being one of the biggest contributors to Python core.
At one point Google employed Guido and he worked on Python there, and I believe they also have made alot of contributions to core.
Can't speak as much to Meta or Netflix though, simply don't have the knowledge
Its an architectural problem, more so than a money one
GvR has contributed very little while at Google.
Even with asyncio most contributions came a) from independent developers who fixed all the mistakes and then b) another non-FAANG developer who augmented it substantially.
FAANG provides power hungry politicians who go for every title and position of power in Python core and the PSF.
The Python speedup project is the first of its kind and so far is based on decades long independent work of Mark Shannon.
I doubt than any JIT expert at Microsoft would want to get involved with PSF politics (career risk), especially because F# and C# are better languages.
(The no-gil project of Sam Gross is the second of its kind, but is unlikely to go in because NIH politics.)
It's the French version of the acronym
in the same case, python prevents a simple interface to do a large number of fairly common tasks, parsing a structured text file, input and output into various data formats, and the tools to build upon your work as it gets more complex.
I'm curious to know what your definition of simple is?
For me, “simple” needs to be distinguished from “familiar”. Most of the time, people think whatever is familiar is simple, but that just makes the word “simple” less useful. The von Neumann style of programming introduces tremendous complexity.
I would probably agree that C is simple in design. I’m not sure, because I’m not extremely proficient in it, but I think I agree. Although it has tons of complexities in practical use… So perhaps it’s easier to speak of (and compare) the simplicity of higher-level languages.
I assume this should read "presents* a simple interface..."?
This is the very premise that I question. Simple in comparison to what? Javascript? I'd actually put python and javascript more or less in the same ballpark of complexity (neither of these are simple languages).
Look carefully at the design of something like Clojure (which has constraints, eg.: around java interop, of a sort that python did not have), and it's hard to unsee all of core python's accidental complexity.
Let me know if you have questions!
But I will say that despite your enthusiasm for inductor/dynamo, I think it's an extremely poor substitute for TS where whole graph compilation is concerned. But hey I get it jansel has spoken and the bright blue future is compiling one stack frame at a time and the graph breaks will continue until morale has improved ;)
Just put nopython=True on it?
I don't think snark from anon accounts are cute btw. Identity or politeness or gtfo.
umm that just percolates up the errors? you're still not guaranteed to successfully get a whole-program graph (only that if you get any graph at all then it is whole-program).
>I don't think snark from anon accounts are cute btw. Identity or politeness or gtfo.
the lady doth protest a little too much, me thinks - i was just making a joke about the transition being top-down rather than bottom-up. also it's not like you have your home address listed here so not sure i should post mine either.
You quoted it wrong
> also it's not like you have your home address listed here so not sure i should post mine either.
tisk tisk you and I both know thats not what I mean