Skip to main content

Posts

py

Python is an amazing programming language, but it has two huge handicaps compared to compiled languages.The first one is GIL or Global Interpreter Lock. GIL is an actual process lock that forces a Python interpreter to work on a single process and use only one of the cores in your CPU. Due to this lock, Python is both simple and stable but also is very slow compared to other programming languages like C or Java.The second handicap is rather universal for non-statically typed aka dynamically typed programming languages. Simply put, when you do not specify the data type of the variable that you are going to use and rely on dynamic type assignment, you end up with much slower execution performance.Luckily there are several ways to speed up your Python code.Bypass GIL (Concurrency/GIL persist)In this approach, the execution of the target code is performed in such a way that data is processed in parallel or concurrently. Essentially, it simply means breaking a single task into multiple sep…

Increase your Instagram followers with a simple Python bot

Growing an audience is an expensive and painful task. And if you’d like to build an audience that’s relevant to you, and shares common interests, that’s even more difficult. I always saw Instagram has a great way to promote my photos, but I never had more than 380 followers... Every once in a while, I decide to start posting my photos on Instagram again, and I manage to keep posting regularly for a while, but it never lasts more than a couple of months, and I don’t have many followers to keep me motivated and engaged.The objective of this project is to build a bigger audience and as a plus, maybe drive some traffic to my website where I sell my photos!A year ago, on my last Instagram run, I got one of those apps that lets you track who unfollowed you. I was curious because in a few occasions my number of followers dropped for no apparent reason. After some research, I realized how some users basically crawl for followers. They comment, like and follow people — looking for a follow bac…

Constants in python - The workaround!

Having transitioned from other languages, including PHP and JavaScript, constants are engrained in my practice.
When I adopted Python, I quickly found myself asking the question, does Python have constants?
The answer is kind of, but not really. Let’s dig deeper!
What is a Constant?




Before we move on, let’s define what a constant is, in case you’re unfamiliar.

A constant value is similar to a variable, with the exception that it cannot be changed once it is set. Constants have a variety of uses, from setting static values to writing more semantic code.

How to Implement Constants in Python
I said earlier that Python “kind of, but not really” has constants. What does that mean? It means that you can follow some standard conventions to emulate the semantic feel of constants, but Python itself does not support non-changing value assignments, in the way other languages that implement constants do.
If you’re like me and mostly use constants as a way of writing clearer code, then follow these guidel…