Yet for all its popularity, Python is often misperceived as slow, clumsy and limited to small projects. The reality is, Python is a powerful and flexible language. It enables development teams to rapidly develop robust, elegant solutions to tough problems. In this article, I’ll bust four myths about Python and explain why it’s so valuable.
Myth 1: “Python is just a scripting language.”
A scripting language operates atop an existing software system to extend its functionality. However, the term is more often used as a sneaky pejorative to imply limits on a language’s usefulness. The speaker often wants to frighten others into using the “real” language they prefer instead.
While Python excels in the role of a literal scripting language, it is by no means limited to this functionality. We can compare it to the Java programming language, long a staple of serious software engineering. Both languages sport the ability to interface with the network and operating system; for this reason, Python is a mainstay in server and network automation. Extensive standard libraries and development ecosystems enable both to excel in almost any practice area. Python is very much Java’s functional equal in all regards.
Myth 2: “Python is slow.”
Because Python is an interpreted language, there is some truth to this. There are many implementations of the Python language and most are slower than languages like Go and Rust. For this reason, some developers are hesitant to use it for performance-critical projects, such as API backends and big data pipelines, yet Python actually excels at both!
Not all Python interpreters have the same performance. One of these, PyPy, implements a just-in-time compilation strategy similar to the Java JVM and thus achieves Java-like performance.
Python also supports binary extensions, which allow communication with compiled C code, typically to handle CPU-intensive operations. Libraries like numpy, Modin and Pillow use them to boost performance. Python can even interface with code from other languages via the CFFI binary extension. A few tools can even compile parts of your Python code to machine code in advance.
Finally, the default Python interpreter, CPython, is undergoing significant improvement. Python 3.11 is showing performance improvements between 10-60% over 3.10 and even higher compared to Python 3.9 and earlier. The notion of CPython being sluggish is starting to become a thing of the past.
Myth 3: “Python is single-threaded.”
A single Python process cannot use more than one CPU core, because of the language’s Global Interpreter Lock (GIL), which actually improves interpreter performance. Nonetheless, Python is fully capable of parallelism and concurrency, which are crucial tools for creating responsive user experiences and performing complex computations.
Asynchrony and traditional threading make concurrency possible in Python. Parallelization is achieved through multiprocessing and extended via libraries like Ray, Dask and JobLib, all of which bypass the GIL. Binary extensions can also be used to parallelize expensive operations.
If anything, the delineation between parallelism and concurrency gives developers more control over when and how to use each.
Myth 4: “Python is weakly typed”
Static typing, specifying the data types for variables, is familiar for many developers. For them, Python’s dynamic typing system can feel a bit like working without a safety net at first. Once you’re used to it, however, it is one of Python’s greatest strengths.
Should I Use Python?
Selecting a language for a project is not a simple process. It helps to consider both the technical needs of the project and the existing team’s skills and knowledge. Python isn’t necessarily the answer to all your problems, any more than Java is, but it certainly bears consideration. Anything you can do in Java or another programming language, you can do in Python, and usually with significantly simpler code. Testing, style and code quality are easily implemented, thanks to tools and standards oriented around evolving best practices. All this saves significant development time, both up front and in maintenance.
About the Author
Jason C. McDonald is a Principal Consultant at Rural Sourcing. As a Python expert, he’s a speaker and the author of “Dead Simple Python” (No Starch Press). When he’s not coding, he’s usually writing fiction books, playing piano, or spending time with his mother and two dogs.
Five Ways to Make Scrum More Developer-FriendlyRead More
Four Tips for Becoming a Product-Minded CIORead More
Removing the Chains of “On-Premise”: Five Steps to Becoming Cloud ReadyRead More
Meet the Virtual Hackathon Planning Committee: Vanessa CooperRead More