[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [pygame] Constant identity



== always does an "is" test first before it tries any harder, so it's
usually safest to use ==, and use "is" only
when you're comparing objects and you really
care about pointer identity. (Personally, I think "is"
should go away in favor of the existing id(x)==id(y).)
Also, some python ints are dynamically created objects and some aren't,
depending on how big they are, so "0+QUIT is QUIT" doesn't have
to be true, but probably is.
I'd be surprised if you noticed a measurable
speed difference in a real program, especially
one with gfx drawing - I'd be interesting to know if you do.
-
m

-----Original Message-----
From: owner-pygame-users@seul.org [mailto:owner-pygame-users@seul.org]On
Behalf Of Magnus Lie Hetland
Sent: Monday, June 03, 2002 2:05 PM
To: PyGame Users
Subject: [pygame] Constant identity


Hi!

I think I've asked about this before, but is it safe to rely on
constant identity in Pygame? I.e. is it OK to say

  if event.type is QUIT: ...

rather than

  if event.type == QUIT: ...

? (That would, of course, require that the event module used the same
constants, and not just equal integers.)

I believe that Pete confirmed this earlier, but I just need to make
sure :)

--
Magnus Lie Hetland                                  The Anygui Project
http://hetland.org                                  http://anygui.org
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org