Python

Lindenmayer System Translator in Python

According to the third question of a computer science homework, it is about Lindenmayer System Translator. Lindenmayer system aka L-system is a formal grammar for modeling the growth process of plant development. In fact, it is very easy to implement L-system as long as we understand the grammar. In Python, implementing L-system is very very easy.

How to measure memory consumption of a program on Linux

According to the hard fight which is a comparison of Java, Python and Ruby side by side, the performance is very impressive because Python is faster than the rest. A java guru immediately identified flaws of this test in Java codes. In addition, he also improved the codes for getting faster program. However, he was too busy to perform the benchmarks again himself. I volunteered to do this task on my laptop. After preparing all codes in Java, Python and Ruby, I have to measure how long it takes to execute each code. The tool I used was "time". Everything went well until I was asked to also measure memory consumption in each case. time always gave me zero without any error message. It seems this is a bug in Linux kernel that getrusage() will return zero in all memory related values. Fortunately, I found a workaround using Python!

Mandelbrot Set Viewer using wxPython

In previous post, I benchmarked several implementation of Mandelbrot Set in Python. To make it more complete, I port a Mandelbrot Set Viewer written in Ruby posted at Codenone using OpenGL to Python and wxPython.

Mandelbrot Set in Python

I found a good homework and posted at Codenone since last week. The first question is about Mandelbrot Set. Actually, this problem could be categorized in compute intensive which should be solved in low-level language to let it run as fast as possible. However, we are talking about alternative languages aka scripting languages like Python and Ruby so I will try to solve this problem in Python. For the solution in Ruby, please go to another post.

How to format decimal number in Python

I got a question about formating decimal number in Python by adding comma in appropriate positions. The most recommend approach is to use built-in locale support. In my opinion, this is not too difficult to implement and there are many approaches. I just want to give an example here as a guideline.

How to use GCD in RSA

As I posted about Greatest Common Divisor last week, I also promised to discuss the application of GCD. Note that if you are interesting in Ruby, I recommend to read about GCD in Ruby at this blog. Actually, GCD is very simple concept. The only application of GCD I known for many years is to find Prime number. Theoretically, a number x will be a prime number if its GCD is 1. Actually, what we used for recent years are running GCD seamlessly. For example, private key infrastructure or PKI is heavily used GCD for finding a pair of keys.