[Yum-devel] [PATCH] clean up misc.to_xml(), make it faster, add tests. BZ 716235.
Toshio Kuratomi
a.badger at gmail.com
Fri Nov 16 18:19:44 UTC 2012
On Nov 16, 2012 9:17 AM, "Zdenek Pavlas" <zpavlas at redhat.com> 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
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-deve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20121116/8d159751/attachment.html>
More information about the Yum-devel
mailing list