From 4466a7f6b2f5d8717e857fb6f3e0efb5976d9051 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Tue, 1 Nov 2005 13:10:38 +0000 Subject: [PATCH] isinstance(a, foo) is faster that type(a) == foo --- src/common/connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index ab720ce1f..fda71b409 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -247,7 +247,7 @@ class Connection: if vc.getTag('vCard').getNamespace() == common.xmpp.NS_VCARD: card = vc.getChildren()[0] vcard = self.node_to_dict(card) - if vcard and vcard.has_key('PHOTO') and type(vcard['PHOTO']) == type({}) and \ + if vcard and vcard.has_key('PHOTO') and isinstance(vcard['PHOTO'], dict) and \ vcard['PHOTO'].has_key('BINVAL'): photo = vcard['PHOTO']['BINVAL'] avatar_sha = sha.sha(photo).hexdigest() @@ -1941,7 +1941,7 @@ class Connection: for i in vcard: if i == 'jid': continue - if type(vcard[i]) == type({}): + if isinstance(vcard[i], dict): iq3 = iq2.addChild(i) for j in vcard[i]: iq3.addChild(j).setData(vcard[i][j])