Python Code Optimization

Performance optimization is making a program run faster, and also is closely related to refactoring

Typically, an 80/20 rule applies. A 20% effort is needed to implement the bulk of the program. Then another 80% effort (and budget) is needed to optimize, refactor, extend and/or document the program.

You first need the program to produce correct results (with correct input) before you know what is making it slow. Do not worry about performance during development.

Continue reading “Python Code Optimization”

[Docker] Basic commands

Docker is a platform for developers and sysadmins to develop, deploy, and run applications with containers. The use of Linux containers to deploy applications is called containerization. Containers are not new, but their use for easily deploying applications is

First touch

Ensure you’ve installed Docker already by the command:

docker --version

Run a docker image

docker container run httpd:2.4

Note: while httpd is the image name, “2.4” is the version of this image

Continue reading “[Docker] Basic commands”

Stack vs Heap

The Stack

What is the stack? It’s a special region of your computer’s memory that stores temporary variables created by each function (including the functionmain()). The stack is a “LIFO” (last in, first out) data structure, that is managed and optimized by the CPU quite closely. Every time a function declares a new variable, it is “pushed” onto the stack. Then every time a function exits, all of the variables pushed onto the stack by that function, are freed (that is to say, they are deleted). Once a stack variable is freed, that region of memory becomes available for other stack variables.

Continue reading “Stack vs Heap”

Celery – Introduction

Task Queue?

Task queues are used as a mechanism to distribute work across threads or machines. The task is appended to the queue that calls task queue. Dedicated worker processes constantly monitor task queues for new work to perform.

Celery communicates via messages, usually using a broker to mediate between clients and workers. To initiate a task the client adds a message to the queue, the broker then delivers that message to a worker.

A Celery system can consist of multiple workers and brokers, giving way to high availability and horizontal scaling.

Continue reading “Celery – Introduction”