Beware of These Potential Python Programming Pitfalls

Are there ANY pitfalls to using Python?

There are a lot of good reasons to use Python. That made me wonder what the downsides were. So, I set out in search of the answer to my question: What are the downsides to using Python?

Honestly, I didn’t find much. I just found a few things worth taking a slightly closer look at before sharing. Below are some highlights from my first pass at researching potential python pitfalls.

Speed:  Python is slower than C or C++

I know that some developers perceive Python as being slow! Hmmm. As a non-developer, my first question was, “Slow, how?”. What does it mean when someone says a language is slow? Well, apparently it can mean one of two things.

  • Slower speed of development refers to slow code/project delivery.
  • Slower speed of execution refers to the code’s performance or ability to perform the job that the developer intends for it to do.

With respect to speed of development…

  • Monterail’s recent performance tests found that “Python absolutely outperforms other languages in terms of delivery speed”.
  • According to Mark, Lutz, author of the book on Learning Python “Python’s speed of development gain is often far more important than any speed of execution loss – especially given modern computer speeds.”
  • In fact, he indicates that you might not even care about execution speed differences depending on the kind of program you need to write.

With respect to speed of execution…

  • I learned that Python code has been optimized a bunch of times and runs fast enough by itself in most application domains.
  • Lutz said that “after 15 years of using Python and 10 years teaching others to use it, execution speed is the only downside. It’s not always as fast as C and C++”.
  • Monterail validates Lutz’s perspective in a study on “program execution speed”. But, the company disagrees with any claim that Python is slow.
  • Yes, they say that “native Python code may seem to have a high execution time when compared to C and C++, but when it comes to commercial use, the speed Python offers is more than satisfactory for most applications – except when using Python to create video games, perform high volumes of calculations or when using compilers.

Database Access Limitations

One Medium article I read said that Python that there are some limitations to using Python to access databases due to the Python database access layer being a bit underdeveloped and primitive. So, it’s not considered suitable if developers are looking for a smooth interaction of complex legacy data.

  • That said, another article on Open Source Forum, points out that the Python programming language has powerful features for database programming. Python supports various databases like MySQL, Oracle, Sybase, PostgreSQL, etc.  In addition, they highlight the fact that there’s also a widely used Python Database API used to create database application programming interfaces, and that Python supports Data Definition Language (DDL), Data Manipulation Language (DML) and Data Query Statements.
  • While I set out in search of database limitation insights, I also discovered the following short list of Python-related database programming benefits:
    • Python is arguably more efficient and faster than other languages.
    • Python is famous for its portability.
    • It is platform independent / agnostic.
    • Python supports SQL cursors.
    • You typically need to take care of the open and closed connections of the database when you use other programming languages to avoid further exceptions and errors. However, you don’t need to do this with Python, because this is already taken care of for you.
    • Python supports relational database systems.
    • Python database APIs are compatible with various databases, so it is very easy to migrate and port database application interfaces.

      Learn more about Python’s DB-API and how to use connection objects, cursor objects, standard exceptions and some other module contents, all of which we will discuss.

Error Detection in Code & Runtime Errors

  • I read that the errors and bugs cannot be detected during compilation because the code is executed through an interpreter – rather than a compiler. I also read that the runtime errors are typically encountered more by people who are “first learning” or “starting to use Python”.
  • Check out this list of 16 common Python runtime error messages that could crash your program.

You can read more about these limitations in this post on Medium.

Here’s a quick list of Pros and Cons of using Python from Squareboat.

Related Posts

Related Articles

Responses

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.