There's more...

Here we will talk about the various implementations of Python available for different platforms and frameworks:

  • Jython: Jython is an implementation of Python for Java Virtual Machine (JVM). Jython takes the normal Python interpreter and modifies it to be able to communicate with, and run on, the Java platform. Thus, seamless integration is established between the two, allowing use of Java libraries and Java-based applications within Python.

While the Jython project has endeavored to ensure that all Python modules will run on JVM, some differences can be found. The main difference is that C extensions will not work in Jython; most Python modules will work without modification in Jython. Any C extensions included in the Python code will not port over correctly. These C extensions should be rewritten in Java to ensure that they work correctly.

Jython code works well within the Java environment, but using standard CPython code (the default Python environment) can have problems. However, Jython code normally runs without issues in the CPython environment, unless it utilizes some sort of Java integration.

  • IronPython: IronPython is Python for Microsoft's .NET framework. IronPython programs can utilize the .NET Framework, as well as regular Python libraries; in addition, other .NET languages (such as C#) can implement IronPython code.

Because of this .NET functionality, IronPython is a great tool for Windows developers or Linux developers using Mono. While normal Python projects can be coded in IronPython, it also allows developers to use Python in place of other scripting languages, such as VBScript or PowerShell. Microsoft's development environment, Visual Studio, has a Python Tools plugin, allowing the full functionality of Visual Studio to be used with Python code.

IronPython is only available for Python 2.7. It has not been ported to Python 3 yet. Back-porting Python 3 code using 3to2 is not guaranteed to work due to the incompatible nature of Python 3 versus Python 2.
  • Stackless Python: Stackless is an enhanced version of Python, focused on improving thread-based programming without the normal complications of regular Python threads. Utilizing microthreads, Stackless aims to improve program structure, make multi-threaded code more readable, and increase programmer productivity.

These improvements are achieved by avoiding the regular C call stack and utilizing a custom stack that is managed by the interpreter. Microthreads handle task execution for a program within the same CPU, providing an alternative to traditional asynchronous programming methods. They also eliminate the overhead associated with multi-threading with single CPU programs, as there is no delay switching between user mode and kernel mode.

Microthreads employ tasklets to represent small tasks within a Python thread and they can be used instead of full-featured threads or processes. Bidirectional communication between microthreads is handled by channels, and scheduling is configured in a round-robin setup, allowing tasklet scheduling either cooperatively or preemptively. Finally, serialization is available via Python pickles to allow delayed resumption of a microthread.

One caveat with Stackless is that, even though microthreads improve upon normal Python threads, they do not eliminate Global Interpreter Lock. Also, tasklets are within a single thread; multi-threading or multi-processing is not being performed.

In other words, true parallel processing is not occurring, only cooperative multitasking within a single CPU that is shared among the tasklets; this is the same functionality as Python multi-threading provides. To utilize parallelism across multiple CPUs, an interprocess communication system would have to be configured on top of Stackless processes.

Finally, because of the changes to the underlying Python source code to implement microthreads, Stackless cannot be installed on top of an existing Python installation. Thus, a complete Stackless installation needs to be installed, separate from any other Python distributions.

  • MicroPython: MicroPython is a stripped-down version of Python 3.4, designed for use with microcontrollers and embedded systems. While MicroPython includes the majority of features within standard Python, a minor number of changes have been made to make the language work well with microcontroller devices. A key feature of MicroPython is that it can run on just 16 KB RAM, with the source code taking up only 256 KB of storage space.

A unique microcontroller, the pyboard, is available for purchase and is designed for use with MicroPython. The pyboard is similar to a Raspberry Pi, except it is even smaller. Yet, it has 30 GPIO connections, four LEDs built-in, an accelerometer, and many other features. As it is designed for use with MicroPython, you essentially get a Python OS that is capable of running on bare metal.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset