Tag: python

Home / python
How To Make Python Faster
Post

How To Make Python Faster

Follow These Quick Wins To Make Python Run Faster Python is too slow, often people complain. But wait, there are many ways to improve its performance This article aims to highlight the key tips in a succinct manner. It is useful for anyone who wants to improve the performance of your python code. I reduced the...

Python Pro Tip: Start using Python defaultdict and Counter in place of dictionary
Post

Python Pro Tip: Start using Python defaultdict and Counter in place of dictionary

How you could use defaultdict and Counter to make your code short and readable Learning a language is easy. Whenever I start with a new language, I focus on a few things in below order, and it is a breeze to get started with writing code in any language. Operators and Data Types: +,-,int,float,str Conditional statements: if,else,case,switch...

Why learn… a statically typed language?
Post

Why learn… a statically typed language?

Most people’s first programming language is a dynamically typed, interpreted language – JavaScript, Python or Ruby. These are excellent languages to learn programming with, and you can be very productive with all three of them. But there’s a separate category of languages in widespred use: statically typed, compiled languages – C, Go, Java, C# and...

Developing Python application: Virtual environment
Post

Developing Python application: Virtual environment

Nowadays Python is everywhere — academics, data science, machine learning, enterprise application, web application, scripting you name it python is everywhere. Whatever you do, python is there either to help you or give you a headache. Let us say, you have learnt python programming and ready to use to develop applications that wow your future employers and...

Explain Python classes and objects to my nephew (+advanced use)
Post

Explain Python classes and objects to my nephew (+advanced use)

It is common secret that Python programming language has a solid claim to being the fastest-growing major programming language witnessing an extraordinary growth in the last five years, as seen by Stack Overflow traffic. Based on data describing the Stack Overflow question views which go to late 2011, the growth of Python relative to five other major...

How to run Python in R
Post

How to run Python in R

Learn how to run Python code inside an R script using the reticulate R package As much as I love R, it’s clear that Python is also a great language—both for data science and general-purpose computing. And there can be good reasons an R user would want to do some things in Python. Maybe it’s a great...

List Comprehension in Python
Post

List Comprehension in Python

Lists are a basic building block for a developer in any language. Python is no different. However at first, list comprehension can sometimes seem confusing. Since it is not an available feature in all languages, it may also be a concept that is completely unfamiliar. Some popular languages that include list comprehension are JavaScript, Perl...

Python Virtual Environments made easy
Post

Python Virtual Environments made easy

I was starting a project where I had to quickly check if a package, Flask, worked with the Python installed on my machine. As I ran the command to install Flask, it alerted me that the package was already installed as I had Anaconda on my machine. But when I tried to run the Hello World Flask app on Sublime...

Python for Data Science: From Scratch
Post

Python for Data Science: From Scratch

Learning about Data Structures and important packages like Numpy and Pandas in Python. This article is the second piece in the Python For Data Science Series. In case you haven’t gone through the introduction of Python(part 1), go ahead and skim through that article here. After knowing about the basics, its time to indulge in more challenging...

Speed Up Your Python Program With Concurrency
Post

Speed Up Your Python Program With Concurrency

Table of Contents What Is Concurrency? What Is Parallelism? When Is Concurrency Useful? How to Speed Up an I/O-Bound Program Synchronous Version threading Version asyncio Version multiprocessing Version How to Speed Up a CPU-Bound Program CPU-Bound Synchronous Version threading and asyncio Versions CPU-Bound multiprocessing Version When to Use Concurrency Conclusion If you’ve heard lots of...

The Ultimate Guide to Python Type Checking
Post

The Ultimate Guide to Python Type Checking

Table of Contents Type Systems Dynamic Typing Static Typing Duck Typing Hello Types Pros and Cons Annotations Function Annotations Variable Annotations Type Comments So, Type Annotations or Type Comments? Playing With Python Types, Part 1 Example: A Deck of Cards Sequences and Mappings Type Aliases Functions Without Return Values Example: Play Some Cards The Any...

Introduction to Python’s Collections Module
Post

Introduction to Python’s Collections Module

Introduction Collections in Python are containers that are used to store collections of data, for example, list, dict, set, tuple etc. These are built-in collections. Several modules have been developed that provide additional data structures to store collections of data. One such module is the Python collections module. Python collections module was introduced to improve the functionalities of the built-in...

Dynamic class definition in Python
Post

Dynamic class definition in Python

Here’s a neat Python trick you might just find useful one day. Let’s look at how you can dynamically define classes, and create instances of them as required. This trick makes use of Python’s object oriented programming (OOP) capabilities, so we’ll review those first. Classes and objects Python is an object-oriented language, meaning it lets you...

Memory Management in Python
Post

Memory Management in Python

Table of Contents Memory Is an Empty Book Memory Management: From Hardware to Software The Default Python Implementation The Global Interpreter Lock (GIL) Garbage Collection CPython’s Memory Management Pools Blocks Arenas Conclusion Ever wonder how Python handles your data behind the scenes? How are your variables stored in memory? When do they get deleted? In...