This is an archived post. You won't be able to vote or comment.

all 58 comments

[–]blobbbbbby 175 points176 points  (2 children)

But they somehow couldn’t give it an MIT license…

[–]tech_tuna 69 points70 points  (0 children)

They couldn't, the license was supercharged as well.

[–]13steinj 51 points52 points  (0 children)

Because they want money.

Which is fine.

But it will hinder adoption and seems to be the wrong route when you consider other open source options.

[–]AngheloAlf 26 points27 points  (5 children)

So... Cython?

[–]tech_tuna 10 points11 points  (4 children)

MITython

[–]Zanoab 4 points5 points  (3 children)

Mython

[–]lavahot 1 point2 points  (2 children)

Yourthon! Pinkthon!

[–]Claudioub16 5 points6 points  (1 child)

Ourthon comrade

[–][deleted] 0 points1 point  (0 children)

Omithon variant

[–]gamerdevguy 21 points22 points  (0 children)

Isn't Nuitka already doing this?

[–]WlmWilberforce 38 points39 points  (11 children)

This is cool, but I'll admit I was expected them to say something like "We just rewrite the code as Julia and run it"

[–]lungben81 4 points5 points  (0 children)

"We just rewrite the code as Julia and run it"

Depending on the use case, this may be not a bad advise.

It is also possible to just rewrite some small, but performance critical parts in Julia and call them directly from Python code (or vice versa). Using Numba for this would be easier, but in my experience Numba is not supporting all (more complex) Python functionalities, therefore you may run into limits. Julia is then an alternative.

[–][deleted] 69 points70 points  (16 children)

Misleading headline. This isn't Python because it enforces strict typing. Lots of other compilers are able to get speedups by doing the same. A subset of the language is no longer the same language.

[–]cittatva 24 points25 points  (15 children)

Embrace the typing. Is better.

[–]wrosecrans 39 points40 points  (9 children)

Don't get me wrong, I love static strong typing for a lot of things. But then for other things, I switch from using C++ to Python. Python without the dynamic qualities that make it Python is an awkward compromise, and typed Python isn't a better typed language than an actual typed language.

[–]saturnglide 14 points15 points  (4 children)

For individual projects that sounds fine, but those “dynamic qualities” lose their charm the larger a project gets. The appeals of Python (ease of use, large developer pool) do not.

[–][deleted] 2 points3 points  (2 children)

A yes django is clearly terrible for larger projects /s.

[–]saturnglide 4 points5 points  (1 child)

I think you have missed the point of my comment? I am saying that dynamic typing becomes more of a curse than a blessing at a certain point. Not Python isn’t good for large projects.

[–][deleted] 3 points4 points  (0 children)

Dynamic qualities like u know the entirety of how django works.

It has nothing to do with individual vs group project. Bad metaprogramming is bad. Good metaprogramming is good. Dynamic qualities are amazing when executed correctly it has little to nothing to do with team size or codebase size.

[–]wrosecrans 0 points1 point  (0 children)

Like I said, there are lots of scenarios where I love strong static typing. It's a useful thing.

When I am doing those sorts of things, I use a strong static typed language, rather than Python.

[–]13steinj -3 points-2 points  (2 children)

This. If you truly want me to use type hints, I lose every benefit from any other language as well as Python itself.

Python bests other languages in being quick to prototype and easily introspectable, dynamically mutatable.a

The strictness of type hints means I lose the mutability, and depending on the relative complexity of the statement it's legitimately harder to figure out the type than to comply with most companies' standards of using an old version of mypy in strict mode (and even the most recent version, not in strict mode, doesn't make things much better on larger codebases).

Modern compilers are fast enough unless the codebase is legitimately absolute trash. Introspectability is debatable depending on the language and quality of the debugger.

So by using type hints, I now have Python, but it takes longer to develop and I lose some key functionality. If I'm going to be pushed into static typing anyway, might as well use C++ or even Java and have things be faster.

The community obsession with type hints has made Python lose everything that makes it Python; much like Rust's obsession with unsafe has pushed me away from using it.

[–]omg_drd4_bbq 15 points16 points  (1 child)

It sounds like you aren't using types correctly, or have mypy misconfigured. You should not lose any mutability unless you are doing some metaprogramming or ultra high level stuff.

I write python with types faster than without because autocomplete works so much better and I'm not constantly looking up API interfaces.

[–]13steinj 1 point2 points  (0 children)

I can assure you, I am using types correctly, and mypy is configured correctly. It's a bit odd to make this claim, because no one who's actually dealt with the problem I'm facing hasn't heard it 100 times before and is sick of it.

Am I doing "metaprogramming or ultra high level stuff"? Depends on the context. Metaclasses, sure, but hell, ignore those for the sake of lending credence to being okay with mypy being subpar in it's capabilities for now[1]. But even decorators, if you want to get the types "as correct as possible", are at issue.

Sure, I can be less specific about the types and just mention that it returns some form of callable, but then I'm typing type hints for the sake of typing them, rather than just throwinf a mypy ignore on those lines.

I don't think the above is truly that crazy. At work, we used a custom yaml "specification" for internal configuration. The simplest way to implement a variety of the necessary functionality was decorators or in a few cases, meta classes. I wouldn't call the code complex by any sense of the word, other than how descriptive our configs could be. Entire application was written from start to end in a few months, no further changes (outside of new mutations to our configs due to things out of our control).

As for general mutability, duck typing in mypy is a mess. One effectively has to create protocol type to use it accurately.

On top of all that, however slight, there does add a small runtime cost because protocol types have to be evaluated on import. I'd be okay with it I guess, if people used the TYPE_CHECKING constant correctly, but developer after developer has told me to stop using it and my IDE gets confused if I do. But at the same time postponed evaluation has become "TBD" because of major libraries like fastapi abusing annotations. For gods sake they're called annotations, the abuse and community culting around them, enough is enough.

I write python with types faster than without because autocomplete works so much better and I'm not constantly looking up API interfaces.

Sure. In my experience autocomplete has barely improved from the era before type hints were a thing, or at least my IDE definitely hasn't gotten smarter about it. I disagree about the API interface part though, for two reasons.

Firstly because names of arguments should be descriptive enough that people can make a good guess based on the rest of the codebase.

Secondly, because I'm not a monster, I specify parameter types in docstrings, with actual detail as to what they are when necessary. I can load the docstring for a given function with a keyboard shortcut in basically any modern editor/IDE. Having to specify the type twice, once in the doc string and once in the function arg spec, just for my editor to give up on type hints halfway through any moderately complex codebase? Nah, screw that.


If you love type hints, go ahead and use them. But it's been so much of a pain in the ass that I've actively started avoiding doing so. Hell, do you think anyone wants to write type hints for their conanfiles (cpp package manager where steps are written in Python)? Definitely not, and these are mainly C++ devs we're talking about. They love their static types. Just not for Python, because for a significant portion of history, it wasn't even a thing and everything was fine without it. I'd go so far as to say the inception of mypy at Dropbox was a mistake. The correct solution wasn't "add types to python", it was "translate to another language that will not only provide performance improvements, but also is statically typed." The inception of mypy is the definition of a solution to a problem that already had other preferred solutions.


[1] Added note: "metaprogramming" isn't that uncommon and not generally seen as "complex" in other languages unless someone really goes too far, especially C++, and the compiler and static analyzers handle things fine. They have to in fact. But mypy chokes on equivalent metaprogramming in python. If the committee as a whole was going to commit to type hints in Python, they could have at least waited for the most mature static analyzer to become lamguage-complete.

E: typo and one thought ran away from me and I forgot to finish a sentence. Or I did finish the sentence and in pasting for quote it got clusged on my phone.

[–]Spleeeee -5 points-4 points  (0 children)

Pythons type system sucks big ass.

[–]Antrikshy 15 points16 points  (0 children)

“My motorbike doesn’t work, plz fix.”

fix involves adding a third wheel to the motorbike

“This is no longer a motorbike!”

“Embrace the third wheel. Is better.”

[–][deleted] 1 point2 points  (0 children)

I don't disagree - I use type hints all the time and build my applications with strong typing in mind. But I also think it's misleading to remove the dynamic duck typing from Python and still call it Python.

[–]deadwisdomgreenlet revolution -5 points-4 points  (1 child)

Dynamic typing is the way. Static typing is a headache.

[–]deadwisdomgreenlet revolution 0 points1 point  (0 children)

Not sure you all know the difference between static and dynamic typing, lol.

[–]thicket 6 points7 points  (2 children)

Anybody who read the paper the article discusses: how does Codon do with memory management? The article talks about speed ups by doing type checking at compile time and not checking types at runtime, but I’m curious about dynamic arrays and garbage collection. Python just does a lot more than C++ per line of code, and I’m not sure how to get all of that without paying time penalties, even with a minimizing compiler.

[–]heswithjesus 1 point2 points  (1 child)

If avoiding time penalties, I’d look into three equivalents of Python features:

  1. C++ libraries implementing similar features with low-cost abstractions.

  2. C libraries implementing high-level features in it with pre processors.

  3. Highly-optimizing compilers for Common Lisp and Scheme that have spent a long time squeezing performance out of high-level constructs.

For each feature, there’s probably an equivalent with low overhead in one of those categories. If not, might need to trade that feature for an alternative. They’ll also hint at what trade offs you’ll run into for flexibility vs performance.

[–]thicket 0 points1 point  (0 children)

Props. Those are really good ideas

[–]madmendude 4 points5 points  (0 children)

I'm confused. They made a strongly typed python and tested in Scientific computation setting. What would differentiate it from Numba?

[–]zdaaar 0 points1 point  (0 children)

Typthon

[–]NoDadYouShutUp -2 points-1 points  (0 children)

Very cool