Blog

Four Myths About Python

Python is one of the fastest growing programming languages, with reported usage rising 20% in the last five years. More than half of developers use Python, with another 8% planning to adopt it in the next year. It holds its own against languages like JavaScript, Java, Kotlin and Go. In fact, I can almost guarantee that your company is using Python for something right now.

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.

Values in Python are still strictly typed. Unlike weakly typed JavaScript, Python won’t let you do surprising things like adding strings and numbers. However, dynamic typing means that code interacts with an object on the basis of capability, greatly simplifying architecture. Once a developer learns to use Python’s dynamic typing to their advantage, it can save them days of effort.

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 Sparq. 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.

 

Related Blogs
See All Blogs
Blog
Sep 18, 2024

Three Tips for Successfully Harnessing Data in AI Implementation

Implementing AI successfully typically hinges on one crucial element: data. Without clean, well-governed and ample data, AI systems can struggle to deliver accurate insights and meaningful actions. In this article, learn three tips for harnessing data effectively in AI implementation.

Read More
Blog
Sep 10, 2024

Discovering Storybook: The Tool that Transforms Your Component Development Process

Component creation is an essential and often intricate part of the web development process. With the increasing complexity of applications, developers face the challenge of ensuring that each component functions correctly and seamlessly integrates within the rest of the system. Learn how Storybook can help.

Read More
Blog
Aug 21, 2024

Why You Should Involve Your CEO in Your AI Implementation Process

Did you know that directly involving your CEO in the AI implementation process can significantly boost your chances of success? In our survey, we found out that companies whose CEO was involved in the AI implementation discussions were more successful in implementing it than those who did not have CEO support. Learn more about why CEO involvement is critical to a successful AI implementation in this article.

Read More
See All Blogs
noun-arrow-2025160 copy 2
noun-arrow-2025160 copy 2
See All Blogs