Tiny/small/minimalist Python?

Discussion in 'Python' started by rtk, Jul 2, 2007.

  1. rtk

    rtk Guest

    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
    rtk, Jul 2, 2007
    #1
    1. Advertising

  2. rtk

    Terry Reedy Guest

    "rtk" <> wrote in message
    news:...
    | 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
    Terry Reedy, Jul 2, 2007
    #2
    1. Advertising

  3. In article <>,
    rtk <> wrote:
    >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.
    Cameron Laird, Jul 2, 2007
    #3
  4. Cameron Laird wrote:
    > In article <>,
    > rtk <> wrote:
    >> 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.


    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.
    Campbell Barton, Jul 2, 2007
    #4
  5. rtk

    Paul Rubin Guest

    rtk <> writes:
    > 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.
    Paul Rubin, Jul 2, 2007
    #5
  6. rtk

    rtk Guest

    On Jul 1, 10:12 pm, Paul Rubin <http://> wrote:
    > 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
    rtk, Jul 2, 2007
    #6
  7. rtk

    Paul Rubin Guest

    rtk <> writes:
    > 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.
    Paul Rubin, Jul 2, 2007
    #7
  8. rtk

    rtk Guest

    On Jul 2, 9:43 am, Paul Rubin <http://> wrote:
    > rtk <> writes:
    > > 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.


    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
    rtk, Jul 3, 2007
    #8
  9. Paul Rubin wrote:
    > rtk <> writes:
    >> 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.


    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
    Irmen de Jong, Jul 3, 2007
    #9
  10. rtk

    rtk Guest

    On Jul 2, 6:26 pm, Irmen de Jong <> wrote:
    > 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
    rtk, Jul 3, 2007
    #10
  11. rtk

    Paul Rubin Guest

    Irmen de Jong <> writes:
    > 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.
    Paul Rubin, Jul 3, 2007
    #11
  12. On Tue, 03 Jul 2007 02:26:43 +0200, Irmen de Jong
    <> declaimed the following in comp.lang.python:


    > 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

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
    Dennis Lee Bieber, Jul 3, 2007
    #12
  13. rtk

    Jorgen Grahn Guest

    Python and ARexx (was Re: Tiny/small/minimalist Python?)

    On Tue, 03 Jul 2007 05:25:28 GMT, Dennis Lee Bieber <> wrote:
    > On Tue, 03 Jul 2007 02:26:43 +0200, Irmen de Jong
    > <> declaimed the following in comp.lang.python:
    >
    >> 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

    ....

    > 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

    --
    // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
    \X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn!
    Jorgen Grahn, Jul 3, 2007
    #13
  14. Re: Python and ARexx (was Re: Tiny/small/minimalist Python?)

    On 3 Jul 2007 10:03:45 GMT, Jorgen Grahn
    <> declaimed the following in
    comp.lang.python:

    >
    > 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

    HTTP://wlfraed.home.netcom.com/
    (Bestiaria Support Staff: )
    HTTP://www.bestiaria.com/
    Dennis Lee Bieber, Jul 3, 2007
    #14
  15. Re: Python and ARexx (was Re: Tiny/small/minimalist Python?)

    Dennis Lee Bieber wrote:
    > On 3 Jul 2007 10:03:45 GMT, Jorgen Grahn
    > <> declaimed the following in
    > comp.lang.python:
    >
    >> 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.


    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
    Irmen de Jong, Jul 3, 2007
    #15
  16. rtk wrote:
    >
    > 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
    Frank Swarbrick, Jul 4, 2007
    #16
  17. In article <468997c7$0$327$4all.nl>,
    Irmen de Jong <> wrote:
    >Paul Rubin wrote:
    >> rtk <> writes:
    >>> 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.

    >
    >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.
    Cameron Laird, Jul 6, 2007
    #17
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Uncle Bob (Robert C. Martin)

    Use Cases -- A minimalist's View

    Uncle Bob (Robert C. Martin), Jul 2, 2003, in forum: Java
    Replies:
    0
    Views:
    751
    Uncle Bob (Robert C. Martin)
    Jul 2, 2003
  2. Sam

    Minimalist executable

    Sam, Aug 15, 2003, in forum: C Programming
    Replies:
    3
    Views:
    528
    Mark McIntyre
    Aug 16, 2003
  3. Replies:
    10
    Views:
    551
  4. Chris Thomasson

    Very Simple, Minimalist Technique For OOP in C...

    Chris Thomasson, Jun 21, 2007, in forum: C Programming
    Replies:
    10
    Views:
    652
    Johan Bengtsson
    Jun 24, 2007
  5. Texas Bob
    Replies:
    0
    Views:
    213
    Texas Bob
    Jul 25, 2009
Loading...

Share This Page