easy question on parsing python: "is not None"
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Aug 6 18:28:52 EDT 2010
On Fri, 06 Aug 2010 15:37:04 +0200, Stefan Schwarzer wrote:
>> Plus, I believe the
>> "==" operator will check if the variables point to the same object.
>
> No, that's what `is` is for.
Actually, yes, equality is implemented with a short-cut that checks for
identity first. That makes something like:
s = "abc"*1000*1000*10
s == s
nice and quick, as Python can immediately recognise that a string is
always equal to itself without having to walk the entire string comparing
each character with itself.
--
Steven
More information about the Python-list
mailing list