Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:23 26 Jul 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micropython is faster than MMBasic :-(

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11662
Posted: 01:51pm 24 Jul 2026
Copy link to clipboard 
Print this post

One of my favourite benchmarks is the calculation of the solar eclipse.

solar_eclipse.zip

The data I use to test with is:
12,1,2000
39,40,36
-104,57,12
1644
30


Running on a HDMI build at 378 MHz this takes 13.23 seconds

Converting this to Micropython 1:1

solar_eclipse_py.zip

This runs in 8.77 seconds at 378MHz!

but Micropython has a trick up its sleeve using the ulab library

solar_eclipse_ulab.zip

And now it runs in 7.44 seconds

For reference if I run the Basic code on a 480MHz STM32H743 which has H/W double precision floating point it takes 7 seconds
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4379
Posted: 02:06pm 24 Jul 2026
Copy link to clipboard 
Print this post

Damn snakes, spoiling it for everyone, can't help but think that happened somewhere else .

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 688
Posted: 02:51pm 24 Jul 2026
Copy link to clipboard 
Print this post

  matherp said  One of my favourite benchmarks is the calculation of the solar eclipse.

solar_eclipse.zip

The data I use to test with is:
12,1,2000
39,40,36
-104,57,12
1644
30


Running on a HDMI build at 378 MHz this takes 13.23 seconds

Converting this to Micropython 1:1

solar_eclipse_py.zip

This runs in 8.77 seconds at 378MHz!

but Micropython has a trick up its sleeve using the ulab library

solar_eclipse_ulab.zip

And now it runs in 7.44 seconds

For reference if I run the Basic code on a 480MHz STM32H743 which has H/W double precision floating point it takes 7 seconds


I notice the BASIC version has a BASIC subroutine for matrix transpose. MMBasic has one built in. Would using the MATH subroutine be faster than the one written in BASIC?
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 2012
Posted: 03:12pm 24 Jul 2026
Copy link to clipboard 
Print this post

BASIC code is the prettiest though  
 
scruss
Senior Member

Joined: 20/09/2021
Location: Canada
Posts: 110
Posted: 01:30pm 25 Jul 2026
Copy link to clipboard 
Print this post

MicroPython has a perfectly good math.atan2(), which will be faster than a hand-rolled equivalent.

MicroPython's complete lack of a useful sgn() function, however, is a pain.

I wonder how much faster it would be compiled with single-precision floating point. That's the norm for MicroPython
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 11662
Posted: 01:36pm 25 Jul 2026
Copy link to clipboard 
Print this post

It would be a lot faster, but, for example, that solar eclipse program simply fails. Any complex math needs double precision
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026