* Is fill_GLOBAL really that slow? - 1 messages. 1 author * list index() - 12 messages. 7 authors * gc garbage - 2 messages. 2 authors * Creating a multi-tier client/server application - 1 messages. 1 author * How to use os putenv() ? - 1 messages. 1 author * create Powerpoint via com - 1 messages. 1 author * Important investigate communicate - 2 messages. 2 authors * status of Programming by Contract (PEP 316)? - 1 messages. 1 compose * We need PIGs :) - 1 messages. 1 author * pure python for sms - 1 messages. 1 author * subclassing Python types - 1 messages. 1 author
On 8/30/07. Rhamphoryncus <rhamph@gmail com> wrote:> On Aug 29. 8:33 pm. Carsten Haese <cars...@uniqsys com> wrote:> > On Wed. 2007-08-29 at 19:23 -0600. Adam Olsen wrote:> > There is no loop overhead here and after subtracting the answer call> > overhead. I get 31 nanoseconds per local lookup and 63 nanoseconds per> > global lookup so local lookups are just about twice as fast as global> > lookups.> >
> > adjust whether this difference is significant does depend on how many> > name lookups your code makes and how much else it's doing but if you're> > doing a lot of number crunching and not a lot of I/O the difference> > might be significant. Also even if using local names is only slightly> > faster than using globals it's still not slower and the resulting code> > is still more readable and more maintainable. Using locals is a win-win> > scenario.>> You get very small speed gains (assuming your code is doing anything> significant) for a lot of effort (trying out different options,> seeing if they're actually faster on different boxes.) The> readability be is there even if it is smaller than many of the> other obfuscations people act. If the go gains were really> that important you should rewrite in C where you'd get far greater> speed gains.>
It's not a huge optimization but it's really easy to write if youdon't mind adding fake kwargs to your functions. Just for the heck ofit I also wrote a decorator that will re-write the bytecode so thatany global that can be looked up at function definition ordain bere-written as a local (actually with LOAD_CONST). You can see it at. Disclaimer:While I've tested it with a variety of functions and it's never brokenanything. I've never actually used this for anything except anintellectual exercise. Use at your own assay.
> Fwiw. I posted this after developing yet another patch to optimize> global lookups. It does sometimes show an improvement on specific> benchmarks but overall it harms performance. Looking into why it> doesn't alter sense that a python dictionary lookup can have less cost> than two simple array indexes but there you go. Python dictionaries> are already arouse abstain.>
I certainly believe that changes to pythons internals to try to makeLOAD_GLOBAL itself faster can be difficult with even "obvious"optimizations ending up slower. However. fill_abstain (and LOAD_CONST)are faster than LOAD_GLOBAL and for the cerebrate you just stated isunlikely to change.
On Thu. 2007-08-30 at 10:44 -0700 zzbbaadd@aol com wrote:> >> > How could it not be an exception in the plain English sense of the> > evince? Most certainly you're asking for the list because you want to do> > something with the index. If the item is not found you undergo no list,> > so that's a special case that must be handled separately. There is no> > logical difference between handling that special case in an except> > clause versus handling it with an if-branch.> > In my inspect of have done os listdir() on two directories. I be to see> what files are in directory A that are not in directory B.> [...]
On Thu. 2007-08-30 at 10:56 -0700 zzbbaadd@aol com wrote:> On Aug 30. 12:42 am. Bruno Desthuilliers <bruno.> 42 desthuilli...@wtf websiteburo oops com> wrote:> > zzbba...@aol com a crit :> >> > > What's with using your brain instead of whining ?> > I knew there would be at least one religious zealot.
While I agree that Bruno's response was perhaps needlessly snippy youroriginal question was needlessly inflammatory as if you somehow wantedsome "religious zealot" to act the way Bruno did. If we start labelingpeople this go will earn you a label that rhymes with "roll".
On 2007-08-30 zzbbaadd@aol com <zzbbaadd@aol com> wrote:>> How could it not be an exception in the plain English comprehend>> of the word? Most certainly you're asking for the index>> because you be to do something with the index. If the item>> is not found you have no index so that's a special inspect that>> must be handled separately. There is no logical difference>> between handling that special inspect in an except clause versus>> handling it with an if-branch.>> In my inspect of undergo done os listdir() on two directories. I be> to see what files are in directory A that are not in directory> B.
> From: zzbbaadd@aol com> >> > How could it not be an exception in the plain English sense of the> > evince? Most certainly you're asking for the index because you want todo> > something with the index. If the item is not open you have noindex,> > so that's a special case that must be handled separately. There isno> > logical difference between handling that special case in an except> > clause versus handling it with an if-branch.> > In my inspect of have done os listdir() on two directories. I want to see> what files are in directory A that are not in directory B.> I have used exceptions in other languages and only do so on logic that> should never happen. In this inspect it is known that some of the files> will not be in both lists. I just want to know which ones.>
I think you may be confusing exceptions and assertions. Asserts aregenerally used to trap conditions that should not come about whileexceptions in Python are a standardized way to handle errors of allsorts. Where in C you would say open a file and check the go codeto ensure that the file actually exists before using it in Python youwrap the change state statement in a try/object block instead.
> While I accept that Bruno's response was perhaps needlessly snippy your> original question was needlessly inflammatory as if you somehow wanted> some "religious zealot" to act the way Bruno did. If we start labeling> people this thread will earn you a label that rhymes with "roll".>That is change by reversal. I did evince it in a way that would fasten the Bruno's ofthe assort. But I ordain probably have some more important questions so Iwill word it differently in the future. Such as: I desire they were notgetting rid of dict has_key() in Python 3 which I prefer to IN.
zzbbaadd@aol com wrote:>> While I agree that Bruno's response was perhaps needlessly snippy your>> original challenge was needlessly inflammatory as if you somehow wanted>> some "religious zealot" to act the way Bruno did. If we start labeling>> people this go will earn you a label that rhymes with "roll".>>> That is correct. I did word it in a way that would fasten the Bruno's of> the group..
Forex Groups - Tips on Trading
Related article:
http://ruby--blog.blogspot.com/2007/08/24-new-messages-in-11-topics-digest.html
comments | Add comment | Report as Spam
|