[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: Use cases for del
From: "George Sakkis" <gsakkis () rutgers ! edu>
Date: 2005-07-08 12:27:07
Message-ID: 1120825627.498017.19370 () g47g2000cwa ! googlegroups ! com
[Download RAW message or body]
"Ron Adam" <rrr@ronadam.com> 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
--
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic