11

Last night I came across the term called Jython which was kind of new to me so I started reading about it only to add more to my confusion about Python in general. I have never really used Python either. So here is what I am confused about.

  1. Python is implemented in C - Does that mean that the interpreter was written in C or does the interpreter convert Python source code into C?

  2. CPython is nothing but the original Python & the term was just coined to later distinguish it from Jython - true or false?

  3. Now that Python is implemented in C (not really sure what that means), but does that mean python can be seamlessly integrated with any C code.

  4. Is Jython like a new programming language or does its syntax & other programming constructs look exactly similar to the original python? or is it just python which can be integrated with java code?

  5. If none of my above questions answer the difference between Python & Jython, what is it?

1
  • 1
    Understanding Jython's relationship to Python and CPython may be easier if you look at some of the other alternative implementations of the python language. The other two that most people talk about are IronPython (Python on .NET), and PyPy (Python in Python... yes, it's trippy). Commented Jan 29, 2011 at 20:16

4 Answers 4

11

"Python" is the name of the language itself, not of a particular interpreter implementation, just as "C" is the name of a programming language and not of a particular compiler.

"CPython" is an implementation of an interpreter of the Python language written in C. It compiles Python source code to byte code and interprets the byte code. It's the oldest and reference implementation of the Python language.

"Jython" is another implementation of the Python language. It translates Python code to Java byte code, which can be executed on a Java virtual machine.

Sign up to request clarification or add additional context in comments.

Comments

7
  1. The former.
  2. I suppose yes. Strictly speaking, "Python" refers only to the language (regardless of the implementation) - but unless the distinction important (e.g. when discussing implementations details), it can also refer to implementations. "CPython" is an unambiguous name for the oldest, most widely-used implementation that's the de-facto standard.
  3. Well, not quite seamlessly. C code that handles Python objects has to juggle with PyObject * and use auxiliary function provided by CPython to convert e.g. a Python integer to a C int. Likewise, C code has to be wrapped with functions taking and returning PyObject *, exposing functions and metadata to the interpreter, etc. You can also use e.g. ctypes for calling native code (although it's often painful), SWIG etc. to automate the wrapping or Cython to write C modules in a Python-C-crossover language.
  4. It's another implementation of Python, i.e. the same language. The main difference is that the code runs on the JVM and can thus integrate easily with Java (or Scala or Closure or any other JVM language).
  5. Python is a language. Jython is an implementation of that language. Do you ask for the difference between C and GCC?

Comments

3

a) Python is a programming language. Interpreters of Python code are implemented using other programming languages like C (PyPy even using Python itself to implement one, I believe).

b) CPython, aka Classic Python, is the reference implementation and is written in C. Jython is a Python interpreter written in Java.

c) Using C libraries in Python is pretty easy, e.g. using the ctypes module.

d) see b.

e) see a and b.

Comments

1

a) Default and most widely used language implementation is written in c also caled CPython. There is also for instance Python implemented in Python - http://codespeak.net/pypy/dist/pypy/doc/

b) CPython is default python implemetation in C. Jython is implemetation in Java.

c) Yes.

d) Jython is implementation of Python language writen in Java.

e) CPython is easly integrated whit C, Jython is easly integrated whit Java.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.