Tiny/small/minimalist Python?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rtk

    Tiny/small/minimalist Python?

    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.pytho n but nothing comes up.

    Thanks!
    Ron

  • Terry Reedy

    #2
    Re: Tiny/small/minimalist Python?


    "rtk" <oneelkruns@hot mail.comwrote in message
    news:1183332951 .122782.212720@ o11g2000prd.goo glegroups.com.. .
    | 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.pytho n 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



    Comment

    • Cameron Laird

      #3
      Re: Tiny/small/minimalist Python?

      In article <1183332951.122 782.212720@o11g 2000prd.googleg roups.com>,
      rtk <oneelkruns@hot mail.comwrote:
      >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.pytho n but nothing comes up.

      Comment

      • Paul Rubin

        #4
        Re: Tiny/small/minimalist Python?

        rtk <oneelkruns@hot mail.comwrites:
        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.

        Comment

        • Campbell Barton

          #5
          Re: Tiny/small/minimalist Python?

          Cameron Laird wrote:
          In article <1183332951.122 782.212720@o11g 2000prd.googleg roups.com>,
          rtk <oneelkruns@hot mail.comwrote:
          >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.pytho n 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.

          Comment

          • rtk

            #6
            Re: Tiny/small/minimalist Python?

            On Jul 1, 10:12 pm, Paul Rubin <http://phr...@NOSPAM.i nvalidwrote:
            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

            Comment

            • Paul Rubin

              #7
              Re: Tiny/small/minimalist Python?

              rtk <oneelkruns@hot mail.comwrites:
              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.

              Comment

              • rtk

                #8
                Re: Tiny/small/minimalist Python?

                On Jul 2, 9:43 am, Paul Rubin <http://phr...@NOSPAM.i nvalidwrote:
                rtk <oneelkr...@hot mail.comwrites:
                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 microcontroller s (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

                Comment

                • Irmen de Jong

                  #9
                  Re: Tiny/small/minimalist Python?

                  Paul Rubin wrote:
                  rtk <oneelkruns@hot mail.comwrites:
                  >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

                  Comment

                  • rtk

                    #10
                    Re: Tiny/small/minimalist Python?

                    On Jul 2, 6:26 pm, Irmen de Jong <irmen.NOS...@x s4all.nlwrote:
                    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

                    Comment

                    • Paul Rubin

                      #11
                      Re: Tiny/small/minimalist Python?

                      Irmen de Jong <irmen.NOSPAM@x s4all.nlwrites:
                      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.

                      Comment

                      • Jorgen Grahn

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

                        On Tue, 03 Jul 2007 05:25:28 GMT, Dennis Lee Bieber <wlfraed@ix.net com.comwrote:
                        On Tue, 03 Jul 2007 02:26:43 +0200, Irmen de Jong
                        <irmen.NOSPAM@x s4all.nldeclaim ed the following in comp.lang.pytho n:
                        >
                        >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.dyn dns.org R'lyeh wgah'nagl fhtagn!

                        Comment

                        • Irmen de Jong

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

                          Dennis Lee Bieber wrote:
                          On 3 Jul 2007 10:03:45 GMT, Jorgen Grahn
                          <grahn+nntp@sni pabacken.dyndns .orgdeclaimed the following in
                          comp.lang.pytho n:
                          >
                          >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:


                          --Irmen

                          Comment

                          • Frank Swarbrick

                            #14
                            Re: Tiny/small/minimalist Python?

                            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

                            Comment

                            • Cameron Laird

                              #15
                              Re: Tiny/small/minimalist Python?

                              In article <468997c7$0$327 $e4fe514c@news. xs4all.nl>,
                              Irmen de Jong <irmen.NOSPAM@x s4all.nlwrote:
                              >Paul Rubin wrote:
                              >rtk <oneelkruns@hot mail.comwrites:
                              >>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.

                              Comment

                              Working...