Re: inline function call

2006-01-06 Thread Xavier Morel
Peter Hansen wrote: > Riko, any chance you could post the final code and a bit more detail on > exactly how much Psyco contributed to the speedup? The former would be > educational for all of us, while I'm personally very curious about the > latter because my limited attempts to use Psyco in th

Re: inline function call

2006-01-05 Thread Michael Spencer
Bengt Richter wrote: ... > > This could be achieved by a custom import function that would capture the AST > and e.g. recognize a declaration like __inline__ = foo, bar followed by defs > of foo and bar, and extracting that from the AST and modifying the rest of the > AST wherever foo and bar call

Re: inline function call

2006-01-05 Thread Bengt Richter
On Thu, 05 Jan 2006 08:47:37 +1100, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Wed, 04 Jan 2006 13:18:32 +0100, Riko Wichmann wrote: > >> hi everyone, >> >> I'm googeling since some time, but can't find an answer - maybe because >> the answer is 'No!'. >> >> Can I call a function in python

Re: inline function call

2006-01-05 Thread Christopher Subich
Diez B. Roggisch wrote: > No. That is simply impossible in python as well as in java where functions > are always virtual, meaning they are looked up at runtime. Because you'd > never know _which_ code to insert of all the different foo()-methods that > might be around there. Not quite "simply imp

Re: inline function call

2006-01-05 Thread Riko Wichmann
Peter Hansen wrote: > > Seeing what others have achieved is always educational to the ignorant, > so I learned something. ;-) Would have been even more educating, if I had my original code still at hand for comparison, which unfortunately I didn't. But all the improvements come from following

Re: inline function call

2006-01-04 Thread bearophileHUGS
I haven't examined the code very well, but generally I don't suggest to use exceptions inside tight loops that that have to go fast. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: inline function call

2006-01-04 Thread Peter Hansen
Riko Wichmann wrote: > the difference between running with and without psyco is about a factor > 3 for my MC simulation. > A factor 3 I consider worthwhile, especially since it doesn't really > cost you much. Definitely. "import psyco; psyco.full()" is pretty hard to argue against. :-) > Th

Re: inline function call

2006-01-04 Thread Steven D'Aprano
On Wed, 04 Jan 2006 13:18:32 +0100, Riko Wichmann wrote: > hi everyone, > > I'm googeling since some time, but can't find an answer - maybe because > the answer is 'No!'. > > Can I call a function in python inline, so that the python byte compiler > does actually call the function, but sort of

Re: inline function call

2006-01-04 Thread Riko Wichmann
Hi Peter, > Riko, any chance you could post the final code and a bit more detail on > exactly how much Psyco contributed to the speedup? The former would be > educational for all of us, while I'm personally very curious about the > latter because my limited attempts to use Psyco in the past ha

Re: inline function call

2006-01-04 Thread bearophileHUGS
Peter Hansen>but I'd be happy to see a real-world case where Psyco gave a much bigger boost.)< Psyco can be very fast, but: - the program has to be the right one; - you have to use "low level" programming, programming more like in C, avoiding most of the nice things Python has, like list generator

Re: inline function call

2006-01-04 Thread Peter Hansen
Riko Wichmann wrote: > That greatly improved performance from about 3 minutes initially (inner > loop about 2000, outer loop about 1 runs - I think) down to a few > seconds. My question on the inline function call was triggered by the 3 > minute run on a pretty small statistic (

Re: inline function call

2006-01-04 Thread Riko Wichmann
, outer loop about 1 runs - I think) down to a few seconds. My question on the inline function call was triggered by the 3 minute run on a pretty small statistic (1 events) Monte Carlo sample. Now, I'm much more relaxed! :) One of the biggest improvements in addition to using psyc

Re: inline function call

2006-01-04 Thread Stuart D. Gathman
On Wed, 04 Jan 2006 13:18:32 +0100, Riko Wichmann wrote: > I'm googeling since some time, but can't find an answer - maybe because > the answer is 'No!'. > > Can I call a function in python inline, so that the python byte compiler > does actually call the function, but sort of inserts it where

Re: inline function call

2006-01-04 Thread Peter Hansen
Riko Wichmann wrote: > def riskfunc(med, low, high): > if med != 0.0: > u = random() > try: > if u <= (med-low)/(high-low): > r = low+sqrt(u*(high-low)*(med-low)) > else: > r = high - sqrt((1.0-u)*(high-low)*(high-me

Re: inline function call

2006-01-04 Thread Rocco Moretti
Riko Wichmann wrote: > hi everyone, > > I'm googeling since some time, but can't find an answer - maybe because > the answer is 'No!'. > > Can I call a function in python inline, so that the python byte compiler > does actually call the function, but sort of inserts it where the inline > call

Re: inline function call

2006-01-04 Thread Peter Hansen
Riko Wichmann wrote: > Can I call a function in python inline, so that the python byte compiler > does actually call the function, but sort of inserts it where the inline > call is made? Therefore avoiding the function all overhead. I know a simple technique that could should basically avoid the

Re: inline function call

2006-01-04 Thread Riko Wichmann
> Do you have an actual use-case for that? I mean, do you have code that runs > slow, but with inlined code embarrassingly faster? Well, I guess it would not actually be embarrassingly faster. From trying various things and actually copying the function code into the DoMC routine, I estimate to

Re: inline function call

2006-01-04 Thread Diez B. Roggisch
Riko Wichmann wrote: > Can I call a function in python inline, so that the python byte compiler > does actually call the function, but sort of inserts it where the inline > call is made? Therefore avoiding the function all overhead. No. That is simply impossible in python as well as in java where

Re: inline function call

2006-01-04 Thread M1st0
I think it does'n exists. But should be. You can also roll up your own using some templating library.. -- http://mail.python.org/mailman/listinfo/python-list

inline function call

2006-01-04 Thread Riko Wichmann
hi everyone, I'm googeling since some time, but can't find an answer - maybe because the answer is 'No!'. Can I call a function in python inline, so that the python byte compiler does actually call the function, but sort of inserts it where the inline call is made? Therefore avoiding the funct