From: jno at glasnet.ru (jno at glasnet.ru)
Date: 22 Apr 1999 11:42:35 GMT
Subject: ``if t'' vs ``if t is not None''
Message-ID: <7fn1vb$rbo$1@news.glas.net>
X-UID: 681                                                  

hi there,

i faced a VERY strange behaviour of if-test operation!

	   ``if t'' != ``if t is not None''
	where ``t'' is None or a class instance

i was writing a threader for a news reader.
and found occasional hangs of a routine which builds the sequence of message
numbers for "read next" operation.
digging deeper brought me strange results: replacing ``if t'' with
``if t is not None'' speeded up the things dramatically!

the call contecst:

      for x in self.keys() :
        m, t = self.mesg_list[ x ]   
        self.Sequence.append( m.num )
        if t is not None :
          t.buildSequence(i+1)
          self.Sequence.extend( t.Sequence )
          del t.Sequence ; t.Sequence = None # trash extra data

can anyone explain me such a phenomenon???

-- 
SY,                       [ mailto:jno at glas.apc.org    ]
jno (PRIVATE PERSON)      [ http://www.glasnet.ru/~jno ]
a GlasNet techie          [ http://www.aviation.ru/    ]
If God meant man to fly, He'd have given him more money.




