[Gambas-user] Gambas is slower than Python??

Benoit Minisini gambas at ...1...
Sun Jan 18 01:31:47 CET 2009


On samedi 17 janvier 2009, birchy wrote:
> I'm quite confused. I'm from a VB6 background, so when i moved to Ubuntu as
> my main O.S. Gambas was very attractive. Several things (mainly poor
> documentation) pushed me to try other languages. Having done a little C,
> C++, Java and PHP, i decided to give Python a go as it's getting very
> popular. I ported a function that i have used for many years in VB6 into
> Gambas and (today) have ported it to Python. Results are quite shocking to
> be honest. The following code takes 4.2sec to run on my oldish AMD 3000 pc.
> The Python version takes 1.9sec. Pythn is "only" a scripting language, so
> what gives??
>
> PUBLIC SUB Main()
>   DIM i AS Integer, t AS Float, s AS String
>
>   t = Timer
>   FOR i = 0 TO 999999
>     s = GetSubstring("QWERTYUIOP", "WE", "IO")
>   NEXT
>   PRINT Timer - t
> END
>
> PRIVATE FUNCTION GetSubstring(doc AS String, startstring AS String,
> endstring AS String) AS String
>   RETURN Split(Split(doc, startstring)[2], endstring)[0]
> END

Interpreter performances depends on its implementation: one may be faster on a 
specific instruction, and slower on another one.

On Gambas, it depends on the version too. Gambas 3 has a lot of optimizations 
compared to Gambas 2.

Can you show us the code in Python? Maybe it will help me to find something 
that could be enhanced in Gambas if Python can do better? :-)

-- 
Benoit Minisini




More information about the User mailing list