Re: Python Optimization

2010-02-16 Thread Paul Boddie
On 14 Feb, 19:41, Steve Howell wrote: > > I ditto the profiling recommendation. > > http://docs.python.org/library/profile.html (To the original inquirer...) Try this, too: http://wiki.python.org/moin/PythonSpeed/Profiling If you have the tools, it's a lot easier than scanning through tables of

Re: Python Optimization

2010-02-15 Thread mukesh tiwari
On Feb 15, 1:07 am, Steve Howell wrote: > On Feb 14, 11:52 am, Mark Dickinson wrote: > > > > > > > On Feb 14, 4:53 pm, mukesh tiwari > > wrote: > > > > Hello everyone. I am new to python and previously i did programming in > > > c/c++.Could some one please help me to improve the run time for thi

Re: Python Optimization

2010-02-14 Thread Steve Howell
On Feb 14, 11:52 am, Mark Dickinson wrote: > On Feb 14, 4:53 pm, mukesh tiwari > wrote: > > > Hello everyone. I am new to python and previously i did programming in > > c/c++.Could some one please help me to improve the run time for this > > python program as i don't have idea how to optimized th

Re: Python Optimization

2010-02-14 Thread Mark Dickinson
On Feb 14, 4:53 pm, mukesh tiwari wrote: > Hello everyone. I am new to python and previously i did programming in > c/c++.Could some one please help me to improve the run time for this > python program as i don't have idea how to optimized this code.This > code also seems to be more unpythonic so

Re: Python Optimization

2010-02-14 Thread Mark Dickinson
On Feb 14, 6:03 pm, a...@pythoncraft.com (Aahz) wrote: > In article > <363498c7-3575-4f1e-ad53-d9cd10c8d...@q16g2000yqq.googlegroups.com>, > Mark Dickinson   wrote: > > >(2) Obvious things: use range rather than xrange in your loops.   > > Um, what?  You meant the reverse, surely? Er, yes I did.

Re: Python Optimization

2010-02-14 Thread Steve Howell
On Feb 14, 9:48 am, Mark Dickinson wrote: > On Feb 14, 4:53 pm, mukesh tiwari > wrote: > > > Hello everyone. I am new to python and previously i did programming in > > c/c++.Could some one please help me to improve the run time for this > > python program as i don't have idea how to optimized thi

Re: Python Optimization

2010-02-14 Thread Aahz
In article <363498c7-3575-4f1e-ad53-d9cd10c8d...@q16g2000yqq.googlegroups.com>, Mark Dickinson wrote: > >(2) Obvious things: use range rather than xrange in your loops. Um, what? You meant the reverse, surely? -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/

Re: Python Optimization

2010-02-14 Thread Mark Dickinson
On Feb 14, 4:53 pm, mukesh tiwari wrote: > Hello everyone. I am new to python and previously i did programming in > c/c++.Could some one please help me to improve the run time for this > python program as i don't have idea how to optimized this code. > [...] How much of a speedup do you need? Ar

Re: Python Optimization

2010-02-14 Thread Mark Lawrence
mukesh tiwari wrote: Hello everyone. I am new to python and previously i did programming in c/c++.Could some one please help me to improve the run time for this python program as i don't have idea how to optimized this code.This code also seems to be more unpythonic so how to make it look like mo

Python Optimization

2010-02-14 Thread mukesh tiwari
Hello everyone. I am new to python and previously i did programming in c/c++.Could some one please help me to improve the run time for this python program as i don't have idea how to optimized this code.This code also seems to be more unpythonic so how to make it look like more pythonic . I am tryi

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-13 Thread John Nagle
Paul Rubin wrote: > "Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > >>And if only the html-parsing is slow, you might consider creating an >>extension for that. Using e.g. Pyrex. > > > I just tried using BeautifulSoup to pull some fields out of some html > files--about 2 million files, output o

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-13 Thread Paul Rubin
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes: > And if only the html-parsing is slow, you might consider creating an > extension for that. Using e.g. Pyrex. I just tried using BeautifulSoup to pull some fields out of some html files--about 2 million files, output of a web crawler. It parsed very

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-12 Thread Diez B. Roggisch
John Nagle wrote: > Diez B. Roggisch wrote: >> Regardless of the possibility of speeding it up - why should one want >> this? Coding speed is more important than speed of coding in 90%+ of all >> cases. > > When you have to start buying more servers for the server farm, > it's a real pain.

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-11 Thread Michele Simionato
On Jun 10, 6:43 pm, John Nagle <[EMAIL PROTECTED]> wrote: > Josiah Carlson wrote: > > Steven D'Aprano wrote: > > >> On Sat, 09 Jun 2007 22:52:32 +, Josiah Carlson wrote: > > >>> the only thing that optimization currently does in Python at present > >>> is to discard docstrings > > >> Python, or

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-11 Thread Steve Howell
--- John Nagle <[EMAIL PROTECTED]> wrote: > > When you have to start buying more servers for > the server farm, > it's a real pain. I'm actually facing that because > Python's HTML > parsing is so slow. > I have been following this thread for a bit, but apologies in advance if I didn't rea

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-11 Thread John Nagle
Diez B. Roggisch wrote: > Regardless of the possibility of speeding it up - why should one want > this? Coding speed is more important than speed of coding in 90%+ of all > cases. When you have to start buying more servers for the server farm, it's a real pain. I'm actually facing that be

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-11 Thread Diez B. Roggisch
>It's hard to optimize Python code well without global analysis. > The problem is that you have to make sure that a long list of "wierd > things", like modifying code or variables via getattr/setattr, aren't > happening before doing significant optimizations. Without that, > you're doomed to a

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-10 Thread Josiah Carlson
John Nagle wrote: > Josiah Carlson wrote: [snip] >> Constant folding happens regardless of optimization level in current >> Pythons. > >> So really, assert and docstring removals. Eh. > >It's hard to optimize Python code well without global analysis. > The problem is that you have to make s

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-10 Thread Steve Howell
--- Kay Schluehr <[EMAIL PROTECTED]> wrote: > On Jun 11, 12:43 am, Steve Howell > <[EMAIL PROTECTED]> wrote: > > > To the extent that some of these optimizations > could > > be achieved by writing better Python code, it > would > > nice for optimization tools to have a "suggest" > mode. > > Is

RE: Python optimization (was Python's "only one way to do it"philosophy isn't good?)

2007-06-10 Thread Doug Phillips
> Is anyone out there who uses MS Word and doesn't deactivate > the "suggest" mode i.e. Clippy? Me... I don't install Clippy (or any of his horribly annoying friends) to start with. :) On the topic though, the suggest mode of the MS help system is generally way off-base, even for my 80-yr-old gr

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-10 Thread Kay Schluehr
On Jun 11, 12:43 am, Steve Howell <[EMAIL PROTECTED]> wrote: > To the extent that some of these optimizations could > be achieved by writing better Python code, it would > nice for optimization tools to have a "suggest" mode. Is anyone out there who uses MS Word and doesn't deactivate the "sugges

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-10 Thread John Nagle
Steve Howell wrote: > --- John Nagle <[EMAIL PROTECTED]> wrote: > >>With this, the heavy optimizations are possible. >>Strength reduction. Hoisting >>common subexpressious out of loops. Hoisting >>reference count updates out of >>loops. Keeping frequently used variables in >>registers. And el

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-10 Thread Steve Howell
--- John Nagle <[EMAIL PROTECTED]> wrote: > > With this, the heavy optimizations are possible. > Strength reduction. Hoisting > common subexpressious out of loops. Hoisting > reference count updates out of > loops. Keeping frequently used variables in > registers. And elimination of > many u

Re: Python optimization (was Python's "only one way to do it" philosophy isn't good?)

2007-06-10 Thread John Nagle
Josiah Carlson wrote: > Steven D'Aprano wrote: > >> On Sat, 09 Jun 2007 22:52:32 +, Josiah Carlson wrote: >> >>> the only thing that optimization currently does in Python at present >>> is to discard docstrings >> >> >> Python, or at least CPython, does more optimizations than that. Aside >>

Re: [Python-Dev] python optimization

2005-09-18 Thread Diez B. Roggisch
Neal Becker wrote: > One possible way to improve the situation is, that if we really believe > python cannot easily support such optimizations because the code is too > "dynamic", is to allow manual annotation of functions. For example, gcc > has allowed such annotations using __attribute__ for qu

RE: [Python-Dev] python optimization

2005-09-16 Thread Neal Becker
One possible way to improve the situation is, that if we really believe python cannot easily support such optimizations because the code is too "dynamic", is to allow manual annotation of functions. For example, gcc has allowed such annotations using __attribute__ for quite a while. This would al

RE: [Python-Dev] python optimization

2005-09-15 Thread Raymond Hettinger
[Neal Becker] > >>I don't know to what extent these kind of optimizations are available to > >>cpython. For example, are constant calculations removed from loops? [Brett Cannon] > > If you mean ``2+3``, then yes. [Greg Ewing] > Actually, no. Constant folding *could* be done, but it currently i

Re: [Python-Dev] python optimization

2005-09-15 Thread Greg Ewing
Brett Cannon wrote: >>I don't know to what extent these kind of optimizations are available to >>cpython. For example, are constant calculations removed from loops? > > If you mean ``2+3``, then yes. Actually, no. Constant folding *could* be done, but it currently isn't: >>> def f(): ... re

Re: [Python-Dev] python optimization

2005-09-15 Thread Brett Cannon
On 9/15/05, Neal Becker <[EMAIL PROTECTED]> wrote: > I use cpython. I'm accustomed (from c++/gcc) to a style of coding that is > highly readable, making the assumption that the compiler will do good > things to optimize the code despite the style in which it's written. For > example, I assume con

Re: python optimization

2005-09-15 Thread Neal Becker
Reinhold Birkenfeld wrote: > David Wilson wrote: >> For the most part, CPython performs few optimisations by itself. You >> may be interested in psyco, which performs several heavy optimisations >> on running Python code. >> >> http://psyco.sf.net/ >> I might be, if it supported x86_64, but AFA

Re: python optimization

2005-09-15 Thread Thomas Heller
Reinhold Birkenfeld <[EMAIL PROTECTED]> writes: > David Wilson wrote: >> For the most part, CPython performs few optimisations by itself. You >> may be interested in psyco, which performs several heavy optimisations >> on running Python code. >> >> http://psyco.sf.net/ >> >> Defining a function

Re: python optimization

2005-09-15 Thread Reinhold Birkenfeld
David Wilson wrote: > For the most part, CPython performs few optimisations by itself. You > may be interested in psyco, which performs several heavy optimisations > on running Python code. > > http://psyco.sf.net/ > > Defining a function inside a loop in CPython will cause a new function > objec

Re: python optimization

2005-09-15 Thread David Wilson
For the most part, CPython performs few optimisations by itself. You may be interested in psyco, which performs several heavy optimisations on running Python code. http://psyco.sf.net/ Defining a function inside a loop in CPython will cause a new function object to be created each and every time

Re: python optimization

2005-09-15 Thread Chris Cioffi
Hi Neal,   I don't believe that cpython currently does any of the optimizations you refer to below.  That said, it is very reasonable to adopt "a style of coding that is highly readable, making the assumption that the compiler will do good things" when coding in Python.  Python is one of the most h

python optimization

2005-09-15 Thread Neal Becker
I use cpython. I'm accustomed (from c++/gcc) to a style of coding that is highly readable, making the assumption that the compiler will do good things to optimize the code despite the style in which it's written. For example, I assume constants are removed from loops. In general, an entity is de