Cobra's performance is close or equal to that of C# and Java,
and is therefore significantly faster than Python.
(from http://cobra-language.com/docs/python/ "...Speed")
Yes, it can be faster!
For example, the Python program Gibberish Detector has a very time-consuming part:
the function train in gib_detect_train.py.
I ported this program to Cobra and wrote two versions: Gib1 and Gib2.
Execution times on a slow computer (1 GHz cpu):
Python
- gib_detect_train.py : 19 seconds
Cobra
- Gib1 : 2 times faster (8 seconds)
- Gib2 : 90 times faster (0.21 seconds)
90 times faster, that's quite impressive!
(Edited: I simplified Gib2, and replaced the uploaded file. )
_____________________________________________
How to build and compare the programs:
- download the Python program from
https://github.com/rrenaud/Gibberish-Detector - copy into a working directory these files:
big.txt, good.txt, bad.txt # these are the input files of "gib_detect_train.py"
Gib1.cobra
Gib2.cobra - compile in the same directory:
cobra -c Gib1
cobra -c Gib2 - execute in the same directory:
Gib1
Gib2 - compare with
gib_detect_train.py # or with
_gib_detect_train.py # (the same code, but with timing and print...)