From ae4d2e2f7d6ec4732018929c54ae6560008930e6 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Sat, 10 Oct 2015 10:44:58 -0700 Subject: [PATCH] init() now directly stores a copy of locals(). We always start with an empty __dict__, and the dict.copy() method appears to be a bit faster than dict.update(). Also, 'self' always exists in locals() so we can just delete that key directly (instead of calling dict.pop()). --- thriftpy/_compat.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/thriftpy/_compat.py b/thriftpy/_compat.py index 81eafcf..cb5a011 100644 --- a/thriftpy/_compat.py +++ b/thriftpy/_compat.py @@ -81,9 +81,8 @@ def __init__(self): varnames = ('self', ) + varnames def init(self): - kwargs = locals() - kwargs.pop('self') - self.__dict__.update(kwargs) + self.__dict__ = locals().copy() + del self.__dict__['self'] code = init.__code__ if PY3: