Tiny/small/minimalist Python?

R

rtk

I'm looking for information on building a tiny/small/minimalist/
vanilla python interpreter. One that implements the core language and
a few of the key modules but isn't tied to any specific operating
system.

I guess I'm asking for the smallest subset of the standard Python
source code files that is necessary to get a working interpreter using
a plain C compiler.

Is this even possible? If so, has someone done it already? I've
looked on Google and in comp.lang.python but nothing comes up.

Thanks!
Ron
 
T

Terry Reedy

| I'm looking for information on building a tiny/small/minimalist/
| vanilla python interpreter. One that implements the core language and
| a few of the key modules but isn't tied to any specific operating
| system.
|
| I guess I'm asking for the smallest subset of the standard Python
| source code files that is necessary to get a working interpreter using
| a plain C compiler.
|
| Is this even possible? If so, has someone done it already? I've
| looked on Google and in comp.lang.python but nothing comes up.

Google 'tinypython' and first entry is Mark Hammond's answer to nearly same
question. And some other responses might help you
 
C

Cameron Laird

I'm looking for information on building a tiny/small/minimalist/
vanilla python interpreter. One that implements the core language and
a few of the key modules but isn't tied to any specific operating
system.

I guess I'm asking for the smallest subset of the standard Python
source code files that is necessary to get a working interpreter using
a plain C compiler.

Is this even possible? If so, has someone done it already? I've
looked on Google and in comp.lang.python but nothing comes up.
.
.
.
Tiny Python, PyMite, EmbeddedPython, Diet Python, deeply embedded
python, ...--I need to write up a page that explains these.
 
C

Campbell Barton

Cameron said:
.
.
.
Tiny Python, PyMite, EmbeddedPython, Diet Python, deeply embedded
python, ...--I need to write up a page that explains these.

Python binary/exe its self dosnt include much. if you get the full build
and just remove modules, you can strip a lot out.. scripts that try
import those files just wont work.
 
P

Paul Rubin

rtk said:
I'm looking for information on building a tiny/small/minimalist/
vanilla python interpreter. One that implements the core language and
a few of the key modules but isn't tied to any specific operating
system.

You've gotten good suggestions about Python configurations. Depending
on your application you might look at alternative languages as well.
Lua and Hedgehog Lisp both come to mind as small embedded interpreters.
 
R

rtk

You've gotten good suggestions about Python configurations. Depending
on your application you might look at alternative languages as well.
Lua and Hedgehog Lisp both come to mind as small embedded interpreters.

PyMite will get a closer look from me eventually but I found that Lua
will fit my immediate needs quite nicely. Thanks for the suggestion.

FYI.. I wanted a simple version of Python to run on an ancient DEC
Alpha box. I got VMS Python 2.5 up and running but it is too slow to
use. It takes *minutes* to get the interpreter prompt after typing
'python'! Lua, on the other hand, compiled without changes (used the
ANSI switch) and runs nicely. I'm always up for learning a new
language anyway.

Ron
 
P

Paul Rubin

rtk said:
FYI.. I wanted a simple version of Python to run on an ancient DEC
Alpha box. I got VMS Python 2.5 up and running but it is too slow to
use. It takes *minutes* to get the interpreter prompt after typing
'python'!

Something is wrong. Maybe it's trying to DNS itself and timing out,
or something like that.
 
R

rtk

Something is wrong. Maybe it's trying to DNS itself and timing out,
or something like that.

The trouble is that the Alpha is too old. VMS Python is compiled for
a newer machine with a different instruction set and the Alpha is
emulating the machine instructions it does not have (a nice feature of
OpenVMS, but of dubious value).

For my needs, the effort of recompiling all of Python wasn't worth
it. Since Lua runs under Unix it will be perfect for my project. I'm
writing a compiler for a simple language to 6502 assembly code. I've
already written one in Python for small PIC microcontrollers (see PIC0
at http://www.geocities.com/oneelkruns/) and was planning on using
Python for this compiler project as well but it will be fun to use
something new, too. I am thinking of doing most of the development in
OpenVMS, just for the heck of it.

Ron
 
I

Irmen de Jong

Paul said:
Something is wrong. Maybe it's trying to DNS itself and timing out,
or something like that.

Something is definately wrong.

Back in the days my port of Python to the Commodore Amiga machine ran
quite comfortably on a 50 mhz CPU with 4 Mb of RAM. (ok ok it was
Python 1.5.2, that has to be said).
Python started in about 5 seconds on that Amiga if I remember
correctly. I'm quite sure your 'ancient' DEC Alpha box is way more
powerful than my Amiga back then.

--Irmen
 
R

rtk

Back in the days my port of Python to the Commodore Amiga machine ran
quite comfortably on a 50 mhz CPU with 4 Mb of RAM. (ok ok it was
Python 1.5.2, that has to be said).
Python started in about 5 seconds on that Amiga if I remember
correctly. I'm quite sure your 'ancient' DEC Alpha box is way more
powerful than my Amiga back then.

Yes, I agree (the box in question is an AlphaServer 1000 4/200), but
the killer is the fact that the Alpha is emulating *machine
instructions* that are part of the Python image which are not part of
the instruction set of that Alpha. That's what kills performance.
When I asked about it on the VMS Python forum I was told to give my
Alpha to a museum and get a more powerful machine :)

I did look briefly at Python 1.5.2, since it is simpler, but I'm
taking the trouble I've had as an excuse to learn a new language. So
far, I'm liking Lua, save the big pet peeve of starting indices at 1
and not 0 as all sane people do. I'm currently using Python quite a
bit for other projects, so it won't be neglected.

Ron
 
P

Paul Rubin

Irmen de Jong said:
Back in the days my port of Python to the Commodore Amiga machine ran
quite comfortably on a 50 mhz CPU with 4 Mb of RAM. (ok ok it was
Python 1.5.2, that has to be said).

Even that sounds way too slow. Kyoto Common Lisp started in a few
seconds on a Microvax-class machine, and an Alpha running Vax
emulation should be at least as fast as that. Python shouldn't have
especially worse startup overhead than KCL unless it's doing something
silly.

I'd try running Python under a profiler and figure out what's slowing
it down. I don't understand the point of developing something in Lua
on a Unix system. Lua is a cute scripting language that's easier to
embed and sandbox than Python and is smaller, but the language itself
is not nearly as nice to code in. I suggested Lua because I was
imagining some kind of memory-limited embedded application that needed
a lightweight extension language without too much of an OS interface,
and Lua is good for that. Using it to write a compiler sounds
masochistic. If there's an obstacle to using Python, I'd even
consider using KCL (or its current incarnation), which has its own
compiler (compiles Lisp to C code) among other things. It does need
several MB of memory.
 
D

Dennis Lee Bieber

Back in the days my port of Python to the Commodore Amiga machine ran
quite comfortably on a 50 mhz CPU with 4 Mb of RAM. (ok ok it was
Python 1.5.2, that has to be said).
Python started in about 5 seconds on that Amiga if I remember
correctly. I'm quite sure your 'ancient' DEC Alpha box is way more
powerful than my Amiga back then.
And your's was likely more powerful than mine... I only had 2MB and
no MMU

1.5.2 was great (and even more fun combined with ARexx)
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
J

Jorgen Grahn

....

And your's was likely more powerful than mine... I only had 2MB and no MMU
1.5.2 was great (and even more fun combined with ARexx)

How does Python combine with ARexx? Can you control applications
which provide an ARexx interface?

I stopped using my Amiga 4000/030 in 1996 or so, long before I
realized C isn't always the best choice for getting things done. I
messed around a bit with ARexx though, and while I found it neat to be
able to script an application from the inside or from the outside
using ARexx, I didn't really care for the language itself -- too
primitive for anything but the tiniest programs.

/Jorgen
 
D

Dennis Lee Bieber

How does Python combine with ARexx? Can you control applications
which provide an ARexx interface?
Irmen had supplied a Python module that had ARexx port operations.

Though I'll admit I never got much beyond testing that...

My first "real" Python program was a rudimentary sendmail daemon --
this was back before any of the Amiga email programs were configured for
their own SMTP/POP3 access. The POP3 program I had was okay, but the
first SMTP process did not "relay" via ISP -- it attempted to send the
body to the host of EACH addressee... And if it couldn't make a
connection, it would hang the entire outgoing queue as it retried every
10 minutes or so -- until I'd have to delete the message from the queue.

The second program I obtained did relay via my ISP -- but I
discovered the author of it had a very weak understanding of the
protocol; it only handshaked using "To:" addressees; "CC:" and "BCC:"
addressees were never sent the mail.

About that time, I discovered the first two Python books at the late
Computer Literacy... A week later I'd coded a program that would take a
formatted message from a "queue" directory, pull the addressees for
handshaking (and strip out the BCC) and relay via my ISP. The ARexx
aspect was that I used an ARexx script as the "send" command from the
mail client -- it took the message (piped by the client), put it into
the "queue" along with a small control file, and checked if the daemon
was running, starting it if needed.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
I

Irmen de Jong

Dennis said:
Irmen had supplied a Python module that had ARexx port operations.

It was not only possible to control a program with an ARexx port from your
Python programs, but it was also possible to create an ARexx host program
in Python. That is: a program exposing an ARexx command port to receive
ARexx messages. This could be done in a few lines of (python) code.

If you're interested, a bit more info is on the AmigaPython page:
http://www.monkeyhouse.eclipse.co.uk/amiga/python/

--Irmen
 
F

Frank Swarbrick

rtk said:
I did look briefly at Python 1.5.2, since it is simpler, but I'm
taking the trouble I've had as an excuse to learn a new language. So
far, I'm liking Lua, save the big pet peeve of starting indices at 1
and not 0 as all sane people do.

Hmm, that in and of itself sounds like a good enough reason for me to
check it out! I despise zero-based subscripts. If I wanted to program
in assembler then I'd program in assembler!

:)

Frank
 
C

Cameron Laird

Something is definately wrong.

Back in the days my port of Python to the Commodore Amiga machine ran
quite comfortably on a 50 mhz CPU with 4 Mb of RAM. (ok ok it was
Python 1.5.2, that has to be said).
Python started in about 5 seconds on that Amiga if I remember
correctly. I'm quite sure your 'ancient' DEC Alpha box is way more
powerful than my Amiga back then.

--Irmen

Me, too.

I'm all for Lua--I began promoting it over ten years ago. However,
I was also working on Alphas at about that time, as well as VMS, and
of course with Python. While I don't recall that I ever had occasion
to test Python under VMS for Alpha much, I've used every other
combination quite a bit. Something's fishy about this report of a
minute-long launch-time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top