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
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
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
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
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
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
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
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
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
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
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 (1 events)
Hey guys,
thanks for all the quick replies! In addition to the tips Peter and
Stuart gave me above, I also followed some of the hints found under
http://wiki.python.org/moin/PythonSpeed/PerformanceTips
That greatly improved performance from about 3 minutes initially (inner
loop about 2000, out
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
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
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
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
> 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
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
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
19 matches
Mail list logo