functools – lru cache

In this article we are going to demonstrate the usage of lru_cache from functools as a decorator to reduce the program execution speed. Here I have written a function to calculate nth Fibonacci number, but calculating it every time takes enormous amounts of time, hence I’ve used lru_cache from functools package. lru stands for least recently used. It stores […]

Read More

Top 10 math functions in python

The math module provides us various functions. Some of them are discussed in this article. Import the math function to begin. The ten methods in this article are ceil and floor factorial gcd sqrt pow sin, cos, tan exp fabs isclose constants Ceil and floor functions The ceil() method returns an integer which is greater […]

Read More

Measure execution time in python using timeit module

By reading this article, you will learn how to measure the performance and execution time of your code in Python. According to the official documentation, the timeit module: “…provides a simple way to time small bits of Python code. It has both a Command-Line Interface as well as a callable one. It avoids a number of common traps […]

Read More

Collections in python – named tuple, deque, counter

Python collections are a module in the Python Standard Library, containing extra features and data types that you can use to your advantage. In this article, I plan to touch the 3 most common and usable ones, but I encourage you to research more. namedtuple namedtuple is an easy way to represent a small simple […]

Read More