davemds pushed a commit to branch master. http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=d3f98802b06fd71d25dc64e1ca41732b73750a77
commit d3f98802b06fd71d25dc64e1ca41732b73750a77 Author: Dave Andreoli <[email protected]> Date: Sat Nov 22 14:25:39 2014 +0100 Optimize the _set_properties_from_keyword_args() function. We do not need to check if the attribute exist to raise an exception, setattr() yet raise a well formatted expection in case of failure. This way we avoid a dir() call and an IN check in a hot path. The only drawback is that this change the raised exception in the case an attr not exist, from AssertionError to AttributeError... I hope none was using that eception explicitly. --- efl/eo/efl.eo.pyx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/efl/eo/efl.eo.pyx b/efl/eo/efl.eo.pyx index 6a2cd03..2b140a8 100644 --- a/efl/eo/efl.eo.pyx +++ b/efl/eo/efl.eo.pyx @@ -237,12 +237,9 @@ cdef class Eo(object): return 1 cdef int _set_properties_from_keyword_args(self, dict kwargs) except 0: - if not kwargs: - return 1 - cdef list cls_list = dir(self) - for k, v in kwargs.items(): - assert k in cls_list, "%s has no attribute with the name %s." % (self, k) - setattr(self, k, v) + if kwargs: + for k, v in kwargs.items(): + setattr(self, k, v) return 1 def delete(self): --
