isinstance() is faster than type. pydoc timeit
This commit is contained in:
parent
1a1ec7bfa2
commit
20a7a0c426
|
@ -127,13 +127,14 @@ class Logger:
|
||||||
files.append(ji + '/' + ji)
|
files.append(ji + '/' + ji)
|
||||||
jid = 'gc'
|
jid = 'gc'
|
||||||
show = nick
|
show = nick
|
||||||
if type(tim) == unicode:
|
# convert to utf8 before writing to file if needed
|
||||||
|
if isinstance(tim, unicode):
|
||||||
tim = tim.encode('utf-8')
|
tim = tim.encode('utf-8')
|
||||||
if type(jid) == unicode:
|
if isinstance(jid, unicode):
|
||||||
jid = jid.encode('utf-8')
|
jid = jid.encode('utf-8')
|
||||||
if type(show) == unicode:
|
if isinstance(show, unicode):
|
||||||
show = show.encode('utf-8')
|
show = show.encode('utf-8')
|
||||||
if msg and type(msg) == unicode:
|
if msg and isinstance(msg, unicode):
|
||||||
msg = msg.encode('utf-8')
|
msg = msg.encode('utf-8')
|
||||||
for f in files:
|
for f in files:
|
||||||
path_to_file = os.path.join(LOGPATH, f)
|
path_to_file = os.path.join(LOGPATH, f)
|
||||||
|
|
|
@ -61,18 +61,19 @@ class OptionsParser:
|
||||||
if value == None:
|
if value == None:
|
||||||
return
|
return
|
||||||
value = value[1]
|
value = value[1]
|
||||||
if type(value) == unicode:
|
# convert to utf8 before writing to file if needed
|
||||||
|
if isinstance(value, unicode):
|
||||||
value = value.encode('utf-8')
|
value = value.encode('utf-8')
|
||||||
else:
|
else:
|
||||||
value = str(value)
|
value = str(value)
|
||||||
if type(opt) == unicode:
|
if isinstance(opt, unicode):
|
||||||
opt = opt.encode('utf-8')
|
opt = opt.encode('utf-8')
|
||||||
s = ''
|
s = ''
|
||||||
if parents:
|
if parents:
|
||||||
if len(parents) == 1:
|
if len(parents) == 1:
|
||||||
return
|
return
|
||||||
for p in parents:
|
for p in parents:
|
||||||
if type(p) == unicode:
|
if isinstance(p, unicode):
|
||||||
p = p.encode('utf-8')
|
p = p.encode('utf-8')
|
||||||
s += p + '.'
|
s += p + '.'
|
||||||
s += opt
|
s += opt
|
||||||
|
|
Loading…
Reference in New Issue