4 ms·
Don't see c/c++ target in the roadmap, which seems like an ideal use case for typed python besides correctness. Thoughts?
by fuzzythinker 10y ago
Don't see c/c++ target in the roadmap, which seems like an ideal use case for typed python besides correctness. Thoughts?
- ddorian43 10y agoWhat ? You mean like export to c/c++ code? Isn't python too dynamic for that ?
- fuzzythinker 10y agoI'll say python isn't any more dynamic than ruby and groovy, and they have fairly stable and usable static compile target release/ports [1]. Python has a few [2] attempts, but none of them is close to stable or really useful. [1] https://crystal-lang.org/ https://crystal-lang.org/ http://groovy-lang.org/releasenotes/groovy-2.0.html http://groovy-lang.org/releasenotes/groovy-2.0.html [2] https://github.com/shedskin/shedskin https://github.com/shedskin/shedskin https://github.com/codeblazer-io/blazescript https://github.com/codeblazer-io/blazescript https://github.com/serge-sans-paille/pythran https://github.com/serge-sans-paille/pythran
- ddfisher 10y agoDon't forget Cython [1]! My understanding is that it's quite useable (though it unfortunately uses a different static type system/syntax than mypy). [1] http://cython.org/ http://cython.org/
- fuzzythinker 10y agoDidn't forget it, just didn't include it since to me, it's more like a totally different (and not pretty) language that tries to look like python. I should however include Nuitka [1] since it is fairly usable, it's just the generated version isn't much faster than its interpreted python version. [1] http://nuitka.net/ http://nuitka.net/
- Macha 10y agoWhy does the same not apply to Crystal then?
- fuzzythinker 10y agoGuess you can say Crystal is a totally different language as well. It's just to me, Crystal still has the same feel as ruby and Cython doesn't. Again, it's just my opinion, I won't argue if you feel otherwise.
- int_19h 10y agoWhy is Cython a totally different language? It's definitely a superset, what with all the custom syntax for type annotations, struct definitions etc. But you can ignore all that, and just stick to the pure Python subset.
- chrisseaton 10y agoYou're arguing that dynamic functionality doesn't stop you being able to statically compile Ruby, giving Crystal as an example - a language which had to drop most of the dynamic functionality of Ruby to achieve better performance.
- vorg 10y ago> groovy, and they have fairly stable and usable static compile target release Citing some Groovy 2.x Release Notes to prove a claim of "stability" for Groovy is like quoting an advertisement for Parmolux washing powder to prove its "effectiveness" at washing out dirt. Not many developers bother with Groovy's static compilation annotations. It's used mainly as a scripting language for testing Java classes, gluing together Java programs, as a build DSL in Gradle, and scripting in Grails. When static annotations are used, their use is typically small-scale.
- jjawssd 10y ago[Cython] is a programming language that makes writing C extensions for the Python language as easy as Python itself. It aims to become a superset of the [Python] language which gives it high-level, object-oriented, functional, and dynamic programming. Its main feature on top of these is support for optional static type declarations as part of the language. The source code gets translated into optimized C/C++ code and compiled as Python extension modules. This allows for both very fast program execution and tight integration with external C libraries, while keeping up the high programmer productivity for which the Python language is well known. The primary Python execution environment is commonly referred to as CPython, as it is written in C. Other major implementations use Java (Jython [Jython]), C# (IronPython [IronPython]) and Python itself (PyPy [PyPy]). Written in C, CPython has been conducive to wrapping many external libraries that interface through the C language. It has, however, remained non trivial to write the necessary glue code in C, especially for programmers who are more fluent in a high-level language like Python than in a close-to-the-metal language like C. Originally based on the well-known Pyrex [Pyrex], the Cython project has approached this problem by means of a source code compiler that translates Python code to equivalent C code. This code is executed within the CPython runtime environment, but at the speed of compiled C and with the ability to call directly into C libraries. At the same time, it keeps the original interface of the Python source code, which makes it directly usable from Python code. These two-fold characteristics enable Cython’s two major use cases: extending the CPython interpreter with fast binary modules, and interfacing Python code with external C libraries. While Cython can compile (most) regular Python code, the generated C code usually gains major (and sometime impressive) speed improvements from optional static type declarations for both Python and C types. These allow Cython to assign C semantics to parts of the code, and to translate them into very efficient C code. Type declarations can therefore be used for two purposes: for moving code sections from dynamic Python semantics into static-and-fast C semantics, but also for directly manipulating types defined in external libraries. Cython thus merges the two worlds into a very broadly applicable programming language. def primes(int kmax): cdef int n, k, i cdef int p[1000] result = [] if kmax > 1000: kmax = 1000 k = 0 n = 2 while k < kmax: i = 0 while i < k and n % p[i] != 0: i = i + 1 if i == k: p[k] = n k = k + 1 result.append(n) n = n + 1 return result http://cython.readthedocs.io/en/latest/src/tutorial/cython_tutorial.html http://cython.readthedocs.io/en/latest/src/tutorial/cython_t...