On Nov 16, 2012 9:17 AM, "Zdenek Pavlas" <[email protected]> wrote:
>
> Hi,
>
> > type checking is better done with isinstance
>
> isn't "type() is" significantly faster?
>
Interesting, it is. I wan't aware of that.
I suppose it depends on how widely you think this code will be used. "type
is" is an equality comparison. isinstance takes inheritance into account.
So to be truly generic you'd want to use isinstance. But since this is
only likely to be used from yum related code trading for speed seems like a
good idea.
> > unicode('item', 'utf-8') was a runaway winner.
>
> Didn't know that, Thanks!
>
> > Should probably have a final else: clause here. It can be as simple
> > as throwing an TypeError exception
>
> Yes, that would be nice..
>
> > item = item.replace("'", ''')
>
> Seems to be a good idea.
>
> > replacing and killing of bad bytes with a single call to
item.translate()
>
> Tried that, too. unicode.replace(dict) is surprisingly slow.
> With the same test case, this scored some 0.180s
>
> _______________________________________________
> Yum-devel mailing list
> [email protected]
> http://lists.baseurl.org/mailman/listinfo/yum-deve
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel