Why not a Python compiler?

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

    Why not a Python compiler?


    ( Surely if this question has been asked for a zillion of times... )
    ( and sorry for my english! )

    I'm impressed with python. I'm very happy with the language and I
    find Python+Pygame a very powerful and productive way of writing 2D
    games. I'm not, at this moment, worried about execution speed of the
    small game I'm working on (it runs at full 60 fps even in an old AMD-
    K6 450 Laptop computer), but I continue asking me the same question:

    Why not a Python COMPILER?

    It would be very nice to be able to output Linux, MAC or Windows
    binaries of compiled (not bytecompiled) code. It would run faster, it
    will be smaller in size (I think) and it will be easy to distribute to
    people not having python installed. Yes, I know about py2exe, but I'm
    not sure if that's the right aproach.

    So, what's wrong with compiling python?

    Maybe is not possible due to nature of the language? Is just a
    decision?

    What do you think about this?
  • cokofreedom@gmail.com

    #2
    Re: Why not a Python compiler?

    On Feb 5, 9:19 am, Santiago Romero <srom...@gmail. comwrote:
    ( Surely if this question has been asked for a zillion of times... )
    ( and sorry for my english! )
    >
    I'm impressed with python. I'm very happy with the language and I
    find Python+Pygame a very powerful and productive way of writing 2D
    games. I'm not, at this moment, worried about execution speed of the
    small game I'm working on (it runs at full 60 fps even in an old AMD-
    K6 450 Laptop computer), but I continue asking me the same question:
    >
    Why not a Python COMPILER?
    >
    It would be very nice to be able to output Linux, MAC or Windows
    binaries of compiled (not bytecompiled) code. It would run faster, it
    will be smaller in size (I think) and it will be easy to distribute to
    people not having python installed. Yes, I know about py2exe, but I'm
    not sure if that's the right aproach.
    >
    So, what's wrong with compiling python?
    >
    Maybe is not possible due to nature of the language? Is just a
    decision?
    >
    What do you think about this?
    I don't know the exact details but I think the issue is the dynamic
    nature of Python makes it impossible to correctly store the various
    types and changes into compiled code. Someone else will probably be
    able to provide a good reason as to why it isn't very feasible, nor a
    good idea. If you want to speed up your python look at Psyco.

    Comment

    • Jeroen Ruigrok van der Werven

      #3
      Re: Why not a Python compiler?

      -On [20080205 09:22], Santiago Romero (sromero@gmail. com) wrote:
      Why not a Python COMPILER?
      A lot of things within Python are very run-time dependent so creating a
      compiler is not trivial work.

      There are, however, endeavours underway like shed skin:



      This provides a Python to C++ compiler, but it enforces some restrictions on
      Python's code.

      --
      Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org/ asmodai
      イェルーン ラウフロッ ク ヴァン デル ウェルヴェ ン
      http://www.in-nomine.org/ | http://www.rangaku.org/
      We have met the enemy and they are ours...

      Comment

      • Kay Schluehr

        #4
        Re: Why not a Python compiler?

        On Feb 5, 9:19 am, Santiago Romero <srom...@gmail. comwrote:
        ( Surely if this question has been asked for a zillion of times... )
        Sure. You can access comp.lang.pytho n via google.google.c om. It has a
        search function.



        Comment

        • Dustan

          #5
          Re: Why not a Python compiler?

          On Feb 5, 2:37 am, Kay Schluehr <kay.schlu...@g mx.netwrote:
          On Feb 5, 9:19 am, Santiago Romero <srom...@gmail. comwrote:
          >
          ( Surely if this question has been asked for a zillion of times... )
          >
          Sure. You can access comp.lang.pytho n via
          groups
          .google.com.
          It has a
          search function.

          Comment

          • Bruno Desthuilliers

            #6
            Re: Why not a Python compiler?

            Santiago Romero a écrit :
            ( Surely if this question has been asked for a zillion of times... )
            Why not checking this by yourself ? google is down ?-)
            I'm impressed with python. I'm very happy with the language and I
            find Python+Pygame a very powerful and productive way of writing 2D
            games. I'm not, at this moment, worried about execution speed of the
            small game I'm working on (it runs at full 60 fps even in an old AMD-
            K6 450 Laptop computer), but I continue asking me the same question:
            >
            Why not a Python COMPILER?

            It would be very nice to be able to output Linux, MAC or Windows
            binaries of compiled (not bytecompiled) code.
            Ah, sorry.
            It would run faster, it
            will be smaller in size (I think)
            These two points are very questionnable given Python's dynamicity. IIRC,
            some guru already made the point, a couple or more years ago, that it
            would be a lot of effort and buy *very* few wrt/ execution speed since
            everything still have to happens at runtime. IOW, a JIT compiler seems a
            far better solution, but this (so far) still impose some (serious)
            limitations to be of any help.



            Comment

            • Ripter001@gmail.com

              #7
              Re: Why not a Python compiler?

              Why not a Python COMPILER?
              What about a Python JIT hardware chip, so the CPU doesn't have to
              translate. Although it seems to me that with today's dual and quad
              core processors that this might be a mute point because you could just
              use one of the cores.

              Comment

              • Steve Holden

                #8
                Re: Why not a Python compiler?

                Ripter001@gmail .com wrote:
                > Why not a Python COMPILER?
                >
                What about a Python JIT hardware chip, so the CPU doesn't have to
                translate. Although it seems to me that with today's dual and quad
                core processors that this might be a mute point because you could just
                use one of the cores.
                >
                What about a chip that reads your mind and does what you want it to?

                I am sure that would be popular with all the frustrated computer users
                there are in the world.

                regards
                Steve
                --
                Steve Holden +1 571 484 6266 +1 800 494 3119
                Holden Web LLC http://www.holdenweb.com/

                Comment

                • Jeff Schwab

                  #9
                  Re: Why not a Python compiler?

                  Steve Holden wrote:
                  Ripter001@gmail .com wrote:
                  >> Why not a Python COMPILER?
                  >>
                  >What about a Python JIT hardware chip, so the CPU doesn't have to
                  >translate. Although it seems to me that with today's dual and quad
                  >core processors that this might be a mute point because you could just
                  >use one of the cores.
                  >>
                  What about a chip that reads your mind and does what you want it to?
                  +1!
                  I am sure that would be popular with all the frustrated computer users
                  there are in the world.
                  I'll take two. (Chips, not frustrated users).

                  --
                  "I sold the cow for these magic ICs," said Jack.

                  Comment

                  • Jeff Schwab

                    #10
                    Re: Why not a Python compiler?

                    Steve Holden wrote:
                    Ripter001@gmail .com wrote:
                    >> Why not a Python COMPILER?
                    >>
                    >What about a Python JIT hardware chip, so the CPU doesn't have to
                    >translate. Although it seems to me that with today's dual and quad
                    >core processors that this might be a mute point because you could just
                    >use one of the cores.
                    >>
                    What about a chip that reads your mind and does what you want it to?
                    +1!
                    I am sure that would be popular with all the frustrated computer users
                    there are in the world.
                    I'll take two. (Chips, not frustrated users).

                    --
                    "I sold the cow for these magic ICs," said Jack.

                    Comment

                    • Jeff

                      #11
                      Re: Why not a Python compiler?

                      I'm surprised no one has mentioned Pyrex. It can be used to write
                      stand-alone C programs using near-Python syntax:

                      Pyrex: http://www.cosc.canterbury.ac.nz/gre.../python/Pyrex/
                      Stand-alone how-to: http://www.freenet.org.nz/python/embeddingpyrex/
                      Pyrex how-to: http://ldots.org/pyrex-guide/,
                      http://www.artfulcode.net/articles/e...-python-pyrex/ (shameless
                      plug, I know)

                      Comment

                      • Ripter001@gmail.com

                        #12
                        Re: Why not a Python compiler?

                        On Feb 5, 11:44 am, Steve Holden <st...@holdenwe b.comwrote:
                        Ripter...@gmail .com wrote:
                        Why not a Python COMPILER?
                        >
                        What about a Python JIT hardware chip, so the CPU doesn't have to
                        translate. Although it seems to me that with today's dual and quad
                        core processors that this might be a mute point because you could just
                        use one of the cores.
                        >
                        What about a chip that reads your mind and does what you want it to?
                        >
                        I am sure that would be popular with all the frustrated computer users
                        there are in the world.
                        >
                        regards
                        Steve
                        --
                        Steve Holden +1 571 484 6266 +1 800 494 3119
                        Holden Web LLC http://www.holdenweb.com/
                        I'm not sure where that came from. Microsoft had talked about a
                        hardware JIT for .NET a few years back. I was just wondering if anyone
                        had thought of it for python or anything like that.

                        Comment

                        • Steven D'Aprano

                          #13
                          Re: Why not a Python compiler?

                          On Tue, 05 Feb 2008 13:22:13 -0800, Ripter001@gmail .com wrote:
                          On Feb 5, 11:44 am, Steve Holden <st...@holdenwe b.comwrote:
                          >Ripter...@gmai l.com wrote:
                          > Why not a Python COMPILER?
                          >>
                          What about a Python JIT hardware chip, so the CPU doesn't have to
                          translate. Although it seems to me that with today's dual and quad
                          core processors that this might be a mute point because you could
                          just use one of the cores.
                          >>
                          >What about a chip that reads your mind and does what you want it to?
                          >>
                          >I am sure that would be popular with all the frustrated computer users
                          >there are in the world.
                          >>
                          >regards
                          > Steve
                          >--
                          >Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC
                          > http://www.holdenweb.com/
                          >
                          I'm not sure where that came from. Microsoft had talked about a hardware
                          JIT for .NET a few years back. I was just wondering if anyone had
                          thought of it for python or anything like that.

                          Okay, you know how hard it is to create a software JIT compiler for a
                          language as dynamic as Python? It's REALLY HARD, which is why it hasn't
                          already been done[1]. Now you want that done in *hardware*, which is much
                          harder. Who's going to spend the money on R&D?

                          I'm sure there are thousands of l33t hax0rs out there who have thought
                          "Wouldn't it be c00l if there was a chip I could put into my PC to make
                          Python run a million times faster!!!". When I was younger and more
                          stupi^W innocent I had a mad fegairy for Forth and Lisp chips, but their
                          lack of financial viability and their unfortunate habit of actually being
                          *slower* than running the language in software put a big dent in the
                          idea. As general purpose CPUs got faster, the idea of making a specialist
                          language chip is now pretty much dead. Even if you could find a niche
                          market prepared to pay for it, "people who run Python programs" is
                          probably not that market.






                          [1] Apart from some specializing compilers like Pysco



                          --
                          Steven

                          Comment

                          • Steve Holden

                            #14
                            Re: Why not a Python compiler?

                            Steven D'Aprano wrote:
                            On Tue, 05 Feb 2008 13:22:13 -0800, Ripter001@gmail .com wrote:
                            >
                            >On Feb 5, 11:44 am, Steve Holden <st...@holdenwe b.comwrote:
                            >>Ripter...@gma il.com wrote:
                            >>>> Why not a Python COMPILER?
                            >>>What about a Python JIT hardware chip, so the CPU doesn't have to
                            >>>translate. Although it seems to me that with today's dual and quad
                            >>>core processors that this might be a mute point because you could
                            >>>just use one of the cores.
                            >>What about a chip that reads your mind and does what you want it to?
                            >>>
                            >>I am sure that would be popular with all the frustrated computer users
                            >>there are in the world.
                            >>>
                            >>regards
                            >> Steve
                            >>--
                            >>Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC
                            >> http://www.holdenweb.com/
                            >I'm not sure where that came from. Microsoft had talked about a hardware
                            >JIT for .NET a few years back. I was just wondering if anyone had
                            >thought of it for python or anything like that.
                            >
                            >
                            Okay, you know how hard it is to create a software JIT compiler for a
                            language as dynamic as Python? It's REALLY HARD, which is why it hasn't
                            already been done[1]. Now you want that done in *hardware*, which is much
                            harder. Who's going to spend the money on R&D?
                            >
                            I'm sure there are thousands of l33t hax0rs out there who have thought
                            "Wouldn't it be c00l if there was a chip I could put into my PC to make
                            Python run a million times faster!!!". When I was younger and more
                            stupi^W innocent I had a mad fegairy for Forth and Lisp chips, but their
                            lack of financial viability and their unfortunate habit of actually being
                            *slower* than running the language in software put a big dent in the
                            idea. As general purpose CPUs got faster, the idea of making a specialist
                            language chip is now pretty much dead. Even if you could find a niche
                            market prepared to pay for it, "people who run Python programs" is
                            probably not that market.
                            >
                            [1] Apart from some specializing compilers like Pysco

                            >
                            >
                            Quite.

                            regards
                            Steve
                            --
                            Steve Holden +1 571 484 6266 +1 800 494 3119
                            Holden Web LLC http://www.holdenweb.com/

                            Comment

                            • =?ISO-8859-1?Q?Luis_M._Gonz=E1lez?=

                              #15
                              Re: Why not a Python compiler?

                              On 5 feb, 05:19, Santiago Romero <srom...@gmail. comwrote:
                              ( Surely if this question has been asked for a zillion of times... )
                              ( and sorry for my english! )
                              >
                              I'm impressed with python. I'm very happy with the language and I
                              find Python+Pygame a very powerful and productive way of writing 2D
                              games. I'm not, at this moment, worried about execution speed of the
                              small game I'm working on (it runs at full 60 fps even in an old AMD-
                              K6 450 Laptop computer), but I continue asking me the same question:
                              >
                              Why not a Python COMPILER?
                              >
                              It would be very nice to be able to output Linux, MAC or Windows
                              binaries of compiled (not bytecompiled) code. It would run faster, it
                              will be smaller in size (I think) and it will be easy to distribute to
                              people not having python installed. Yes, I know about py2exe, but I'm
                              not sure if that's the right aproach.
                              >
                              So, what's wrong with compiling python?
                              >
                              Maybe is not possible due to nature of the language? Is just a
                              decision?
                              >
                              What do you think about this?

                              There are some projects aimed to speed up Python by a large margin.
                              Right now you can use psyco, which is considered to be feature
                              complete, and whose future relies on the Pypy project.

                              Pypy is a very ambitious project and it aims, amongst many other
                              goals, to provide a fast just-in-time python implementation.
                              They even say that the "secret goal is being faster than c, which is
                              nonsense, isn´t it?" (I still didn´t get the joke though...).

                              And finally, you have ShedSkin, a project developed by one lonely and
                              heroic coder (Mark Dufour).
                              Shedskin aims at being a static python compiler, which can translate a
                              subset of python to stand alone executables.
                              It also can compile extension modules for cpython.
                              It works by translating python to c++ and then to machine code.
                              The python code must be done in a static way (getting rid of dynamic
                              features like, for example, not asigning different types to the same
                              variable).

                              Luis

                              Comment

                              Working...