When most people install Python, they are installing CPython, but there are actually several flavors:

Python Flavor Description
CPython Written in C. The standard and most commonly used implementation.
Brython Runs directly in a browser.
IronPython Written in C#.
Jython Written in Java.
MicroPython Runs on a microcontroller.
PyPy Written in Python.
RubyPython Written in Ruby.

And this list is non-exhaustive!

I've known that many of these variants existed but didn't know much about when to use them, so I made this post to help myself better understand why some of the different flavors exist.

Running performance benchmarks

I often see PyPy used in benchmark tests. It's written with a restricted subset of Python called RPython – Restricted Python – and is a just-in-time compiler, which means that it's often faster than the standard CPython.

For all its speed, PyPy doesn't have full compatibility with the CPython ecosystem, so not all Python code will work. For example, assignment expressions, position-only parameters, and the numpy library don't always work in PyPy. And support for features introduced after Python 3.6 is not guaranteed. In those cases, CPython is the way to go.

Running Python in a browser

The first time I saw Brython, I thought it was cool! Using a <script type="text/python"> tag that enabled me to write pure Python instead of learning Javascript seemed fantastic. Plus, it uses Python 3 syntax and is supported by most modern browsers and smartphones.

That said, I don't see many frameworks built on top of Brython, so complicated DOM manipulation might be more effort than it's worth.

Also, Brython isn't the only way to run Python in a web browser. This article does a deep dive on six different options for running Python in a browser, and I especially love its summary graphic at the top:

Created by Yasoob Khalid: https://yasoob.me/2019/05/22/running-python-in-the-browser/

Running on other language's frameworks

IronPython is written to work closely with .NET applications. There are libraries like Python.NET that allow CPython to work directly with .NET, but the IronPython experience is more polished. It's great for embedding some quick Python into an application, but it feels more like a gateway for easing Python developers into the .NET world.

Similarly, Jython compiles Python code to Java bytecodes that can run directly on the Java Virtal Machine (JVM), and RubyPython allows Python code to be imported into a Ruby application. I'm sure you can guess what RustPython does.

Running for data science

Anaconda Python is a distribution of Python and R that focuses on simplifying package management for data science applications. It comes with tools like numpy and jupyter already installed and the Navigator GUI that allows you to launch and install new packages without a command line. This makes it a great option for data scientists who don't have a strong software development background.

Beware that the Anaconda installation can be 10x larger than CPython (using gigabytes instead of megabytes), so alternatives like Miniconda may be better suited for a system with tighter resource constraints.

Also, strictly speaking, Anaconda is a distribution and not a flavor of Python. I included it in this post only because I wanted to learn more about it while researching some of the other flavors out there.

I should mention that ActivePython exists too, but it doesn't seem to be as popular as Anaconda Python, so I won't dive into details.

Conclusion

This isn't my any means an exhaustive or thorough exploration of all the Python variants out there, but it helped me to organize my thoughts about a few of them. I hadn't truly grasped how versatile Python had become even though I'd known it was growing in popularity, so doing research for this was pretty neat. At some point, I'll put together a timeline to highlight the history of Python.