I agree this following would be cool. However in the general case this type of code inference is HARD to do. I believe that the optimizations you are looking for would require a combination of type inference and graph reduction. PyPy may be the eventual answer. Don't get me wrong, I think it is great and the long term goal. As soon as we compile and run correctly, I'm all about optimizations.
Good Insight Michal, Kevin, Michal Wallace wrote: > Hey Sam, >I agree with what you're saying in this >thread. This is slightly off topic, but >I wanted to point something out. > >In general, python has so many places >where things have to be dynamic that you >really can't know this kind of thing at >compile time, especially if you allow for >eval/exec, or if you allow the code to be >used as a module. > >However if you treat the code as a closed >system, *and* you have access to python at >compile time, then we can optimize away a >lot of these questions. > >For example, in your original code: > > def f(x,y): > return y > > class Foo: > f = f > def g(self,y): > return y > > foo = Foo() > > g=foo.g > > print f(0,1) > print foo.f(2) > print g(3) > > >Once you know how python works, it's *obvious* >that this prints 1,2,3. I see no reason why the >compiler couldn't figure this out up front just >by walking the tree. > >In fact, a good optimizing compiler would see the >"return y" lines and just get rid of those methods >completely. > >I'd like to allow for the ability to do certain >optimizations like this up front, sacrificing >flexibility for speed. I know there are many >programs that won't allow for this, but for the >ones that do, I'd like to be able to do a sort >of static compile like this. > >In other words, sometimes a python-like language >is a desirable thing. (But of course this should >all be optional so that we can also be 100% >python compatible) > >Sincerely, > >Michal J Wallace >Sabren Enterprises, Inc. >------------------------------------- >contact: [EMAIL PROTECTED] >hosting: http://www.cornerhost.com/ >my site: http://www.withoutane.com/ >------------------------------------- > >_______________________________________________ >pirate mailing list >[EMAIL PROTECTED] >http://cornerhost.com/mailman/listinfo/pirate >