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)
|
||||
jid = 'gc'
|
||||
show = nick
|
||||
if type(tim) == unicode:
|
||||
# convert to utf8 before writing to file if needed
|
||||
if isinstance(tim, unicode):
|
||||
tim = tim.encode('utf-8')
|
||||
if type(jid) == unicode:
|
||||
if isinstance(jid, unicode):
|
||||
jid = jid.encode('utf-8')
|
||||
if type(show) == unicode:
|
||||
if isinstance(show, unicode):
|
||||
show = show.encode('utf-8')
|
||||
if msg and type(msg) == unicode:
|
||||
if msg and isinstance(msg, unicode):
|
||||
msg = msg.encode('utf-8')
|
||||
for f in files:
|
||||
path_to_file = os.path.join(LOGPATH, f)
|
||||
|
|
|
@ -61,18 +61,19 @@ class OptionsParser:
|
|||
if value == None:
|
||||
return
|
||||
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')
|
||||
else:
|
||||
value = str(value)
|
||||
if type(opt) == unicode:
|
||||
if isinstance(opt, unicode):
|
||||
opt = opt.encode('utf-8')
|
||||
s = ''
|
||||
if parents:
|
||||
if len(parents) == 1:
|
||||
return
|
||||
for p in parents:
|
||||
if type(p) == unicode:
|
||||
if isinstance(p, unicode):
|
||||
p = p.encode('utf-8')
|
||||
s += p + '.'
|
||||
s += opt
|
||||
|
|
Loading…
Reference in New Issue