12.07.2015 Views

Is Python a

Is Python a

Is Python a

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Python</strong> Implementation AlternativesReally, as this book is being written, there are three primary implementations of the<strong>Python</strong> language—C<strong>Python</strong>, Jython, and Iron<strong>Python</strong>—along with a handful of secondaryimplementations such as Stackless <strong>Python</strong>. In brief, C<strong>Python</strong> is the standardimplementation; all the others have very specific purposes and roles. All implementthe same <strong>Python</strong> language, but execute programs in different ways.C<strong>Python</strong>The original, and standard, implementation of <strong>Python</strong> is usually called C<strong>Python</strong>,when you want to contrast it with the other two. Its name comes from the fact that itis coded in portable ANSI C language code. This is the <strong>Python</strong> that you fetch fromhttp://www.python.org, get with the Active<strong>Python</strong> distribution, and have automaticallyon most Linux and Mac OS X machines. If you’ve found a preinstalled versionof <strong>Python</strong> on your machine, it’s probably C<strong>Python</strong>, unless your company is using<strong>Python</strong> in very specialized ways.Unless you want to script Java or .NET applications with <strong>Python</strong>, you probably wantto use the standard C<strong>Python</strong> system. Because it is the reference implementation ofthe language, it tends to run the fastest, be the most complete, and be more robustthan the alternative systems. Figure 2-2 reflects C<strong>Python</strong>’s runtime architecture.JythonThe Jython system (originally known as J<strong>Python</strong>) is an alternative implementation ofthe <strong>Python</strong> language, targeted for integration with the Java programming language.Jython consists of Java classes that compile <strong>Python</strong> source code to Java byte code andthen route the resulting byte code to the Java Virtual Machine (JVM). Programmersstill code <strong>Python</strong> statements in .py text files as usual; the Jython system essentially justreplaces the rightmost two bubbles in Figure 2-2 with Java-based equivalents.Jython’s goal is to allow <strong>Python</strong> code to script Java applications, much as C<strong>Python</strong>allows <strong>Python</strong> to script C and C++ components. Its integration with Java is remarkablyseamless. Because <strong>Python</strong> code is translated to Java byte code, it looks and feelslike a true Java program at runtime. Jython scripts can serve as web applets andservlets, build Java-based GU<strong>Is</strong>, and so on. Moreover, Jython includes integrationsupport that allows <strong>Python</strong> code to import and use Java classes as though they werecoded in <strong>Python</strong>. Because Jython is slower and less robust than C<strong>Python</strong>, though, itis usually seen as a tool of interest primarily to Java developers looking for a scriptinglanguage to be a frontend to Java code.28 | Chapter 2: How <strong>Python</strong> Runs Programs

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!