Skip to content
Snippets Groups Projects
Commit 20a7a0c4 authored by nkour's avatar nkour
Browse files

isinstance() is faster than type. pydoc timeit

parent 1a1ec7bf
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment