summaryrefslogtreecommitdiff
path: root/efl
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2014-11-22 14:25:39 +0100
committerDave Andreoli <dave@gurumeditation.it>2014-11-22 14:25:39 +0100
commitd3f98802b06fd71d25dc64e1ca41732b73750a77 (patch)
treea50751d2d2c874fdebfffac1fe5dd5be5c7f9597 /efl
parentda1807c379b981ea54733385afc59b205198a8a7 (diff)
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.
Diffstat (limited to 'efl')
-rw-r--r--efl/eo/efl.eo.pyx9
1 files 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):
237 return 1 237 return 1
238 238
239 cdef int _set_properties_from_keyword_args(self, dict kwargs) except 0: 239 cdef int _set_properties_from_keyword_args(self, dict kwargs) except 0:
240 if not kwargs: 240 if kwargs:
241 return 1 241 for k, v in kwargs.items():
242 cdef list cls_list = dir(self) 242 setattr(self, k, v)
243 for k, v in kwargs.items():
244 assert k in cls_list, "%s has no attribute with the name %s." % (self, k)
245 setattr(self, k, v)
246 return 1 243 return 1
247 244
248 def delete(self): 245 def delete(self):