Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to learn python so I downloaded it from the python site and I saw 4 other kinds of pythons appear:
Python (normal)
IronPython
Jython
PyPy
Stackless Python
I can really find what the differents are between these.
Also which one is the best to start with.
Updated to include corrections from kind people in the comments section:
Of the python implementations you mention, the original and most commonly used is CPython (python on your list - which is an interpreter for python implemented in C and running as a native application) and is available for pretty much every platform under the sun. The other variants are:
IronPython: runs on the .Net common runtime (interfaces more cleanly with other .Net apps)
Jython: runs on the JVM (interfaces more cleanly with Java and other JVM apps)
PyPy: A Python interpreter which includes a just-in-time compiler which can significantly increase program execution performance. The interpreter and JIT are implemented in RPython (rather than C), a restricted subset of Python which is amenable to static analysis and type inference.
Stackless Python: An implementation of a python interpreter which doesn't rely on recursion on the native C runtime stack, and therefore allows a load of other interesting programming constructs and techniques (including lightweight threads) not available in CPython.
There are a large variety of libraries for Python (one of the major advantages of the language), the majority developed for CPython. For a number of compatibility reasons, none of the variants above currently support as many as the main implementation. So for this reason, CPython is the best place to start, and then if your future requirements fit one of the other platforms - you'll be in a good place to learn the variations from a solid grounding in the basics.
Python. All the documentation you'll find for learning the language assumes this. Then if you find a need for one of the other implementations the documentation will assume you know Python and explain the differences.
Start with Python.
The alternatives are for special use cases that apply mostly when you are integrating Python with other languages, which is a very advanced usage of the language.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I was googling for some demo Python code I found few sample codes which say they use IronPython, CPython and PyPy so I then searched for what they actually are and found that these are already written code arenas from where we can pick functions and use them. But I am not actually sure on how to use them in my code.
And also can I use all of them at once in my single code.
CPython is the original implementation of the Pythn language (written in C). IronPython is an implementation of the Python language that runs on the .NET framework and PyPy is another implementation of Python using Just-In-Time compilation for faster execution speeds.
They are all Python interpreters, and for learning the language it does not matter much which one you use. I prefer using CPython, since it's pre-installed on many systems, but if you need access to .NET libraries from Python or need faster code, I guess IronPython or PyPy would make sense to use.
Yes, you could use both and PyPy is interpreter and just-in-time compiler focused on speed, efficiency, and compatibility with CPython.
good luck
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Given that the GIL limits pythons ability to support true threads, is it possible to strip it out of current python implementations so that the language can finally support true multithreading. Furthermore, assuming that the GIL is dropped, would that mean that multi-core threading would finally come to scripting/interpreted languages such as Python and Ruby?
Your question is flawed.
Python supports threads just fine. In fact, when you create a thread in a Python program running under a *nix it likely creates exactly one additional pthreads thread, no questions asked.
The only restriction is that Python code won't run in parallel (but it does run concurrently, interleaved, etc.). Code that's not under the GIL, such as almost everything that does I/O, doesn't prevent other threads from running Python code.
As for removing the GIL... it's hard. Like, really really hard. You and me can just assume it's infeasible (hey, at least we'll be pleasantly surprised if some superhuman does succeed). Other implementations (Jython, IronPython) don't have a GIL, but their approaches aren't practical for CPython (and not easy for PyPy either, from what I hear) and they can't exactly replace CPython as they lag behind a lot, don't support C extensions, are less portable to more exotic platforms, etc.
That said, some PyPy developers are working on an STM solution (latest update) that would free PyPy from the GIL. CPython on the other hand? I don't think there's a chance, even with STM, especially when potential ABI and API breakage is taken into account.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is there any interest in developing Rpython (Restricted Python) from the PyPy project as a general purpose programming language? Perhaps it could be a fork from the PyPy project. Does such a project exist? Since the programs are compiled, one could simply contribute modules written in Rpython, and it could compete with other python implementations including CPython and PyPy.
I can't speak for everyone else, but I personally am extremely interested in using RPython as a general-purpose language. To answer some other people's questions:
Why? Because Cython is a pain to figure out how to use. If you don't put in a lot of tricky type declarations just right, you don't get any speedup. With RPython, it will run fast or it won't run at all.
Using PyPy offers a good speedup, but currently not nearly as much as RPython.
RPython might be a good way to get super-fast, somewhat Pythonic code. Here's an example to help you get started. I'm not aware of any large projects to do this, unfortunately.
Yes, there is already a project to use the translation tool chain of PyPy to create standalone executables and libraries using RPython. It is called RPythonic.
A general purpose RPython would not be a competitor for CPython and PyPy. It wouldn't even be a competitor for things like Cython.
Why? Because RPython is not Python!! RPython is merely a language which shares some syntax with Python; enough that a Python interpreter can execute RPython code, but you cannot take Python code and compile it as RPython.
The restrictions on Python that are added to enable RPython to be statically typed and compiled (indeed, to have static type inference) are so severe that they completely change the language. If you want to write an RPython program, you have to decide to do so up front and write it in RPython. You can't write a program in Python and then decide to compile it as RPython, and you can't even tweak a realistic Python program a bit to make it RPython. Normal Python code is nothing like normal RPython code; writing RPython is more similar to writing Java or C#.
So if you want to write general programs in Python but you want them to go faster, RPython has very little to offer you. That's the niche PyPy's Python interpreter is trying to fill.
If you want to write general programs in a lower level compiled language because you need your program to run faster than Python, then there are existing very mature languages and libraries for that, like Java or C#.
The reason to code in RPython would be to do something that is particularly made better by RPython. Like writing interpreters to which you can add garbage collectors and JIT compilers without having to write them by hand! Here RPython shines, and yes I would be very interested in a more polished and usable RPython interpreter-writing environment. But as a general purpose programming language for writing programs that don't particularly benefit from RPython's specialities, it would simply be a monstrous amount of work to get it to the point where it could compete with existing languages that already fill that role better. It barely even has a standard library now (because almost none of Python's extensive standard library is usable in RPython), for example.
From the looks of it, the restrictions are quite severe and on the whole it's a lot less to program in, I imagine. That's necessary for implementing PyPy, but generally if you want fast compiled code that can interact with Python, you'd use Cython (which is targeted at CPython extensions and supports pretty much all of Python seamlessly) or write code in one of the more common languages that can do this. And if you just want fast, compiled code... well, RPython may be more pleasant than e.g. C, but still, I don't see a significant advantage here (at least none that would warrant the effort to create a usable, stable language).
Why would I want to write directly in RPython?
It seems so much simpler to Python code and run PyPy.
Why would I want to write C code?
It seems so much simpler to write Python and have PyPy be implemented in C
Why would I want to write assembler code?
It seems so much simpler to write Python and have PyPy implemented in C and C implemented in Assembler.
I guess it really is turtles all the way down.
Why would I want to stop using the most convenient language and switch to a less convenient language?
What's the value in giving up a nice language?
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am looking for a good scripting language to link to my program.
I am looking for 2 important attributes:
Scripting language should be hard linked into the executable (not requiring 3rd party
installations). This is important to me to simplify distribution.
Scripting should allow some run-time debugging option (When running a script inside my program I would like to easily run it inside a debugger while it is running in the context of my program)
Can python,lua or some other language supply me with this?
Both Lua and Python can provide the features you mention, so choosing one of them will depend on other criteria.
Lua is a lighter weight solution, it will have a much smaller disk footprint and likely a smaller memory overhead than Python too. For some uses it may be faster. Python has a much richer standard library, more mature third party libraries and a more expressive language.
Both have been embedded into major applications. Python can be found in Blender, OpenOffice and Civilization 4. Lua can be found in World of Warcraft and Adobe Lightroom. I'd recommend looking at a few tutorials for each and the facilities available to embed them in your application and just choose the one that fits your brain best.
Lua is designed for this:
static linking? check!
debugging? check!
Typically, Lua is the better choice for embedding into another project. Python is better as a standalone platform because the library support is so much broader. See Lua Versus Python for more details.
Personally, I use both very frequently depending on the job at hand. I always use Lua for embedding into C/C++ applications or scripting functionality that is imported from C/C++ shared libraries (i.e. a DLL). Python is always my first choice for standalone tasks that do not require low-level C/C++ code.
I'd put my two cents in for python. I don't know a lot of the details, but the computer graphics suite blender does a wonderful job of implementing python scripting.
As far as I can tell in blender 2.5 the interpreter is run from inside the executable,
import sys
sys.executable
shows /blender/blender.exe
and there is good debugging support, it even has a full interactive interpreter inside.
For more info check out: http://www.blender.org/
I really like Lua for embedding, but just as another alternative, JavaScript is easily embeddable in C, C++ (SpiderMonkey and V8) and Java (Rhino) programs.
In addition to Tcl, Lua, and Javascript (all already mentioned), Guile is another language designed explicitly for this.
I'll add Tcl to the mix. It's designed to be easily embedded into other programs.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Except for CPython, which other Python implementations are currently usable for production systems?
The questions
What are the pros and cons of the various Python implementations?
I have been trying to wrap my head around the PyPy project. So, fast-foward 5-10 years in the future what will PyPy have to offer over CPython, Jython, and IronPython? and
Migrating from CPython to Jython
already shed some light on the pros/cons on the topic. I am wondering now, if those more exotic implementations are actually used in systems that have to run reliably. (possible examples? open-source?)
EDIT: I'm asking for code that needs the Python version >= 2.5
CPython
Used in many, many products and production systems
Jython
I am aware of production systems and products (a transactional integration engine) based on Jython. In the latter case the product has been on the market since the early 2000's. Jython is a bit stagnant (although it seems to have picked up a bit lately) but it is mature and stable.
IronPython
This is the new kid on the block, although it does have some track record in products. It (particularly version 1.x) can be viewed as stable and ready for production use, and development is officially funded by Microsoft, who appear to have an interest in dynamic languages on top of the CLR. It is the greenest of the major python implementations, but appears to be reasonably stable.
Stackless Python
This is used extensively in EVE Online, and they seem to view it as production ready. Bear in mind that Stackless Python has been around for something like 10 years.
At least one product, Resolver One, is said to be production-level and is totally based on IronPython.
Resolver One is a program that blends a familiar spreadsheet-like interface with the powerful Python programming language, giving you a tool with which to better analyse and present your data.
I know that Jython is pretty mature and has been around for a long time.
Also, I'd take a look at Stackless python
You can check http://www.portablepython.com/ which is the portable version of CPython. It is also bundled with very common and useful libraries and even an IDE, all portable.
There was Pyrex, which can be found at http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/. It is not Python, but very close. The Cython (not CPython) is based on Pyrex and can be found at http://www.cython.org/. They are both useful for creating C extensions for Python. Their languages are so Pythonic.