Posts

Introduction to Git tool and GitHub (2020 tutorial)

Image
  1. Introduction to Git 1.1 The history of git Git is a distributed version control system for tracking code changes during development. It facilitates the team development for projects.  It was designed by Linus Torvalds (creator of Linux) for Linux kernel development in 2005. You could learn more about git on wikipedia . 1.2 Features of git It has two main features:    1. version control It facilitates the team development of projects and help you to maintain development history of your project.    2. a distributed system A Git directory on every computer is a full-fledged working repository with a complete history and full version-tracking capabilities without accessing network. This feature is a total departure from the traditional client-server version control system. 2. Git install and basic use (Ubuntu linux) To install git is just a single line of code on Linux: sudo apt-get install git After installation, just type git to check its command Next, w...

Python advanced #002 shallow copy() and deepcopy() (2020)

Image
1. Introduction to copy module There are two copy method in the copy module, copy.copy() and copy.deepcopy(). Those two methods could cause ambiguity in some cases. So it is crutial that we understant it clearly. 1.1 copy.copy() There are two lists a and b: >>> a = [11,22] >>> b = [33,44] In python, the two lists are stored in different addresses in memory. The variable names "a" and "b" are just like labels attached to the lists and they are also stored in memory too and they know the addresses of those lists. Next, we calculate the addresses of those two lists by using built-in function id(). >>> id(a) 43440616 >>> id(b) 39008264 As you could see, these two have different addresses which means they occupy separate spaces in memory. Next, we create a list "c" out of those two lists "a" and "b": >>> c = [a, b] >>> id(c) 39007720 As you could see, "c" points to a diffrent ad...

Python advanced #001 GIL (2020)

Image
  1. What is GIL? The GIL (global interpreter lock) is used by CPython interpreter which written in C programming language. There are other python interpreters that are written in other languages, such as JPython written in Java. CPython uses this GIL lock to make sure that only one thread executes python bytecode at a time. The other thread must wait for its release. Using this GIL, CPython ensures that when a thread is executing python bytecode, any python objects will not be accessed by another thread. It provides a safe threading way to achieve multitasking. Its downside is more obvious in modern computers which always feature multi-core cpus. Because only one thread could execute code at a time, CPython will only occupy one cpu core at a time leaving other cpu cores idle.  1.1 Why Guido doesn't remove it Actually, Guido (creator of Python) did that several years ago. But eventually, he quit and make a statement that removing the GIL is not an easy task; by removing GIL co...