Re: Use cases for del



"Ron Adam" <rrr@xxxxxxxxxxx> wrote:

> Here's something interesting:
>
> import time
>
> x = None
> t = time.time()
> for i in range(1000000):
> if x==None:
> pass
> print 'None:',time.time()-t
>
> x = 'to-end'
> t = time.time()
> for i in range(1000000):
> if x=='to-end':
> pass
> print 'String:',time.time()-t
>
> >>>
> None: 0.46799993515
> String: 0.360000133514
>
>
> Of course the difference this would make on a single call in practically
> Nill.
>

How about using the right way of comparing with None ?

x = None
t = time.time()
for i in range(1000000):
if x is None:
pass
print 'is None:',time.time()-t

I get:

None: 0.549999952316
String: 0.498000144958
is None: 0.450000047684

> Anyway, time to call it a night so tomorrow I don't make anymore silly
> mistakes on comp.lang.python. :)

That would be a great idea ;-) An even greater idea would be to give up
on this "None should mean undefined" babble; it looks like a solution
looking for a problem and it raises more complications than it actually
solves (assuming it does actually solve anything, which is not quite
obvious).

> Cheers,
> Ron

Cheers,
George

.



Relevant Pages

  • Re: 72-74
    ... comparing them to earlier and later years. ... he could prove that mid-eighties shows consistently have Jerry playing longer ... preferences is personal taste, there's never anything to argue about. ... mistakes are made and suggest ways to fix them. ...
    (rec.music.gdead)
  • Re: Lamar Odom Does Again?
    ... George Evans wrote: ... It is simply saying that he made mistakes in both games, ... SAYING THAT BOTH MISTAKES ARE IDENTICAL OR SIMILAR, OR EVEN COMPARING ...
    (alt.sports.basketball.nba.la-lakers)
  • Re: JSHs mistakes happen all the time
    ... James Harris wrote: ... > Now a poster has found a minor series of mistakes in my APF paper, ... But mistakes happen. ... Are you, in any way, comparing yourself to Andrew Wiles?!? ...
    (sci.math)
  • Re: how to avoid mistaken integer comparisons
    ... trigger the warning for comparing a pointer to an integer. ... Of course, that doesn't prevent your particular bug, but part of learning C is understanding that "foo" and "*foo" are not the same thing; the compiler can't catch all of your mistakes. ...
    (comp.lang.c)
  • Re: Use cases for del
    ... String: 0.498000144958 is None: 0.450000047684 ... mistakes on comp.lang.python. ... on this "None should mean undefined" babble; it looks like a solution looking for a problem and it raises more complications than it actually solves ... several posts. ...
    (comp.lang.python)