Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

Commit

Permalink
init() now directly stores a copy of locals().
Browse files Browse the repository at this point in the history
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()).
  • Loading branch information
jparise committed Oct 10, 2015
1 parent 8cc573d commit ae4d2e2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions thriftpy/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ae4d2e2

Please sign in to comment.