473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

micro-python - is it possible?

Hi,

Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?

In its full form, python is a resource hog. If a microcontroller
implementation honoured the 'everything is an object' philosophy, the
code would spend 80% of the time in memory allocation/deallocation
routines, taking tens or hundreds of times longer for even the simplest
tasks.

One kludge I've come up with towards a micro-python is the use of 'magic
pseudo-functions' that lock in specific types and behaviour, eg:

- in the mainline, outside of any functions:
- x = int16(45)
- creates a signed 16-bit global int called x, initialises it
to 45
- y = const32(0x3342)
- creates a 32-bit constant called y, initialises it to 0x3342,
any attempt to assign to it raises an exception at compile
time
- z = int8()
- creates an uninitialised global byte var called z
- within a function:
- x = uint16(4)
- creates an unsigned 16-bit int on the return stack frame,
called x, initialised to 4

Another kludge is to legislate that 'None' is a 16-bit int with value of
zero, such that:
- return
- return None
- return 0
all do the same thing

Is anyone working along similar lines?

Is it even possible to devise a tiny python subset that has at least
some of python's advantages, but at the same time can be compiled to
low-footprint resource-lean code?

And could such a mini-python be worth using over C, Forth, etc?

Your thoughts?

--
Cheers
EB

--

One who is not a conservative by age 20 has no brain.
One who is not a liberal by age 40 has no heart.
Aug 30 '05 #1
9 5166

"Evil Bastard" <sp**@me.please> schrieb im Newsbeitrag
news:43********@news.orcon.net.nz...
Hi,

Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?

remember there was some work done for minimizing py1.5.2 for mics. see
Google. even bare py1.5.2 would be possible with about 1.5MB overhead
statically compiled.
remember an own short trial on a AMD SC400 with Embedded Linux. all in 4 or
8 MB or so.

but Py2.x's became big nasty beasts with also nasty memory behaviour.

guess py1.5.2 is still very nice, tiny and fast for mics. Happy to have a
good basic script lng you won't use new style / meta classes / iterators
.....
Is it even possible to devise a tiny python subset that has at least
some of python's advantages, but at the same time can be compiled to
low-footprint resource-lean code?

And could such a mini-python be worth using over C, Forth, etc?


guess so if your app has non-trivial complexity: Faktor 5 in programming
speed and clarity of code - if you can grant 0.5..2MB overhead.

but guess you still need some 1%..5% C for time critical stuff.
Robert
Aug 30 '05 #2
Check Lua programing language. Maybe this can fit your requirements.
HTH
Petr Jakes

Aug 30 '05 #3
On 2005-08-30, Evil Bastard <sp**@me.please> wrote:
Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?
No, not a tiny microcontroller environment. In the
microcontroller world, "tiny" means 100 bytes of ram and 4KB of
code space. OTOH, if you want to talk about medium-large uC
stuff (hundreds of KB or RAM and code space), somebody did port
and old version of Python to something like that. Google for
"deeply embedded python".
Is it even possible to devise a tiny python subset that has at least
some of python's advantages, but at the same time can be compiled to
low-footprint resource-lean code?


I doubt it.

--
Grant Edwards grante Yow! I appoint you
at ambassador to Fantasy
visi.com Island!!!
Aug 30 '05 #4
>No, not a tiny microcontroller environment. In the
microcontroller world, "tiny" means 100 bytes of ram and 4KB of
code space.


That's medium :)

PIC10F200: 256 12-bit instructions, 16 bytes RAM.
Wouter van Ooijen

-- ------------------------------------
http://www.voti.nl
Webshop for PICs and other electronics
http://www.voti.nl/hvu
Teacher electronics and informatics
Aug 30 '05 #5
On 2005-08-30, Wouter van Ooijen (www.voti.nl) <wo****@voti.nl> wrote:
No, not a tiny microcontroller environment. In the
microcontroller world, "tiny" means 100 bytes of ram and 4KB of
code space.


That's medium :)

PIC10F200: 256 12-bit instructions, 16 bytes RAM.


Touché

--
Grant Edwards grante Yow! I HAVE a towel.
at
visi.com
Aug 30 '05 #6
Evil Bastard wrote:
Hi,

Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?


Isn't pypy meant to support different backends with different
requirements and constraints using the same basic language?
Aug 30 '05 #7
Magnus Lycka <ly***@carmen.se> writes:
Evil Bastard wrote:
Hi,
Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?


Isn't pypy meant to support different backends with different
requirements and constraints using the same basic language?


Yup, not part of the project that I'm involved in, but it's part of
the plan.

Cheers,
mwh

--
59. In English every word can be verbed. Would that it were so in
our programming languages.
-- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html
Aug 30 '05 #8
Evil Bastard <sp**@me.please> writes:
Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?


We just had this thread a few weeks ago and you decided to use FORTH
that time. The answers are the same this time.
Aug 30 '05 #9
Evil Bastard wrote:
Hi,

Has anyone done any serious work on producing a subset of python's
language definition that would suit it to a tiny microcontroller
environment?


Take a look at PyMite :

http://www.python.org/pycon/papers/pymite/

From the abstract :

"PyMite is a flyweight Python interpreter written from scratch to
execute on 8-bit microcontrollers as well as desktop computers..."

Regards,
Alejandro.
Aug 31 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Eric | last post by:
Help! Install Sun One Studio 4, Micro Edition on Windows ME PLease help: When I install Sun One Studio 4, Micro Edition on Windows ME, it's shown that searching for suitable SDK, and a DOS...
12
by: François | last post by:
Hi, After looking up Microsoft's site for licensing info...and found nothing, I turn to this newsgroup. Does someone know what version of VB .Net you are entitled to use when you are a micro...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
13
by: webzila | last post by:
Hello, I have to write a program for an 8051 micro-controller using micro-C to monitor Switch 1 and if the switch in pushed the message "switch 1 pushed" should be displayed in the LCD. Also the...
2
by: Paul in Toronto | last post by:
First off, this is for a school assignment... I know some people get squeamish about this sort of post, but I'm kind of up a creek. Basically, as part of a semester-long project, we need to add...
2
by: studyandjobs | last post by:
How Micro-pump will change the future of computer/ mobile chips. Engineers at Purdue University have developed a tiny "micro-pump" cooling device small enough to fit on a computer chip that...
2
by: m.a | last post by:
Hello, Is there any fixed point library in .net framework? I need it to use on fixed point processor that doesn't have any floating point co processor Regards
30
by: Ashit Vora | last post by:
Hi, I want to find the current time stamp in micro sec precision. The requirement is, my function is executed in an infinite loop. I measure a value and check if the value computed is what i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.