Hello world demystified

Hacking, Uncategorized
Hello all, in the finest programming tradition, I take it that every time one took a programming course or decided to have a quick look into a programming language, writing a "Hello World" program was one of the first things done. However, even in such a small program, do you really know what it does behind the scenes? Yiannis blogged about it here, giving a Java test case (and by the way, allow me to extend my welcome!) and Dimitris provided a C equivalent there. However, let's do a roundup. After whacking some Perl code, I got the following results Let's start with the old workhorse, Perl: ################################################################################ The Perl version ################################################################################ strace -c -f -q perl hello.pl % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- ---------…
Read More

CPython threading vs multiprocessing – the 5 minute introduction

Hacking, Uncategorized
MJC brought to my attention the following piece of code which attempts to provide some empirical data comparing the use of threads vs processes in CPython. This code, which I understand that it is stored for historical purposes, has some bugs, which I have pointed out in the comment section, but this is not the point of this article (something like this would be not constructive). I believe that a far better contribution would be to write a short piece attempting to point out a few "gotchas". Bit rot took hold and the post above has disappeared but the rest of the article still applies ... For the rest of this small article, I assume that you are familiar with how threads work in CPython, especially the GIL "issue". If…
Read More