- Ray Casting
- Fast Canvas Drawing
- Back to basics - Binary search
- Back to basics - Bubble sort
- Remote machine development
- WebAssembly In The Browser
- WebAssembly Brief Intro
- The Programming Metagame
- Raspberry Pi Zero Cluster
Raybench - Python (PLC pt.7)
With 25 years in development, Python has been evolving from a hobby project to a full blown general purpose language used for scripting, data science, games programming, web servers and more.
For it's characteristics, Python is a imperative and dynamic language with some characteristics from functional programming included; also supporting the object oriented paradigm. It's main selling point is it's readable syntax, that uses indentation to delimit code blocks.
Python 2.7.6 was used for the tests.
How fast does the interpreter loads and parses the source code.
$ time python pyrb.py real 0m0.052s user 0m0.040s sys 0m0.000s
$ time python pyrb.py real 348m35.965s user 345m51.776s sys 0m22.880s
$ time pypy pyrb.py real 14m2.406s user 13m55.292s sys 0m1.416s
The running time for the regular Python interpreter is abysmal, although not as bad as Lua. It gets much better if you are using Pypy, which makes the code run almost as fast as mono.
Line count: 213 code, 57 blanks, 270 total. File size: 5825 bytes.
I ran into several problems while doing the translation of the raybench source to Python, one of the main drawbacks was the way code blocks are defined using indentation. Personally it made the code blocks a bit more difficult to manage while not adding much to readability, also, I had to fight with vim's auto indentation which more often than not, inserted and incorrect amount of spaces for new lines, miss interpreting the context.
On the bright side, Python has great support from libraries for almost any task imaginable, and runs on a great number of different platforms. Also, Pypy is awesomely fast!.
You can follow the development of this project on GitHub: https://github.com/niofis/raybench