Skip to main content

Fixing The Speed of Python


Introduction To Python

Python programming language which was released in the year 1991 by Guido van Rossum a Dutch Programmer from Haarlem, Netherlands.

Guido van Rossum is one of the world's most influential programmers. Van Rossum is the author of the general-purpose programming language Python, which he started working on in 1989, and is now among the most popular languages in use.

Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentation

Multi-paradigm: object-oriented, procedural (imperative), functional, structured, reflective

Advantages 

Python programming language has some advantages and I will only mention few which are:

  • Versatile
  • Code Readability
  • Beginner friendly.

Problems

But even though python is simple Powerful and used in many fields. It still has some downsides. Like:

  • Very Slow - Python is not a fast language it is very slow.

Solution

There are some python libraries that can be used by data scientists to speed up there codes,
libraries like:

  • Threads

Another standard library approach to speeding up Python is to use multi-threading. Python was built as a single-threaded, high-level programming language, so in a lot of ways multi-threading is going to be more difficult when it comes to doing it in Python. However, in most examples it will turn out to be a single simple call to create a new process.
The biggest problem I have found with using threads in Python is that processes are unnamed and not manageable. This means that you can create processes to handle loops and arithmetic for you while you are doing other things, but it is hard to call back to those threads and manage what they are doing. Of course, in most cases that will not be necessary, so this is certainly one that can come in handy for the average Python programmer.

  • Numba

Just In Time compilation, or JIT compilation is a compiling technique that makes the interpreted code compiled and executed and compiled at the same time. Anytime we compile a Python application, consider that there is a certain amount of overhead where data for everything in the code needs to be registered and allocated data. This is so that Python has a reference for this in each scope whenever these objects are called. JIT compilation can be used to reduce this overhead.

With JIT compilation, rather than allocating all of this data prior to running the application, we are doing it as the application is running. This reduces the compilation to execution start times, and just like how doing more than one thing at a time when it comes to threading, doing more than one thing at a time when it comes compilation can also significantly speed up the speed of code.

The package that is typically used for this in Python is a package called Numba. Something great about Numba’s implementation is that it is incredibly easy to use! Numba uses a simple decorator to let Python activate JIT on certain functions and classes

Conclusion

  In conclusion python has some downsides but also has some libraries that can be built to counter those downsides, the libraries that are built are more than the ones I have mentioned in this articles here are links to some articles that will shed light on the few I mentioned and more

https://towardsdatascience.com/5-easy-ways-to-speed-up-python-963c86535eef

Comments

Popular posts from this blog

How to Create a Qrcode Generator in Python.

Firstly before writing the codes for the qr code generator let us first understand what we mean by qr code. What are Qr Codes? Qr Codes which are also known as Quick Response codes are a type of matrix barcodes developed in 1994 by the Japanese automotive company DENSO WAVE by a man named Masahiro hara. Qr Codes can also be defined as a machine-readable code that consists of an array of black and white squares, typically used for storing urls or other information for reading by the camera on a smartphone or smart device.  What are Barcodes? A barcode on the other hand is a machine-readable optical label that can contain information about the item to which it is attached. Coding Time. So we are done with the definition of qr codes and barcodes now let's dive into the coding. Steps to Create the Qr Code Generator. Firstly make sure that python software is installed in your system (more specifically python3), if it is not then go to https://www.python.org/ In order to download th

Coding vs Programming

Today I will be talking about a very big misunderstanding among people which is: The difference between coding and programming these two are taught to be synonymous/similar, well am here to clarify that and fully explain what they are. CODING VS PROGRAMMING Coding and programming are often thought to be the same but they are not, Coding is the process of translating and writing codes from one language to another, whereas Programming is the process of building an executable program that can be used to carry out proper machine level outputs. Coding only deals with the codes, and so it is less intimidating and less intensive. WHERE DOES CODING COME IN? So coding is just part of the process of programming but it's not programming itself, so you can say coding is like pathway you must learn in order to learn programming, because in order to create programs writing codes is a step you must take, and you write these codes in a special language called Programming languages . So I hope t