Author: Armin Rigo <[email protected]>
Branch: py3k
Changeset: r86368:bee473720d24
Date: 2016-08-21 10:24 +0200
http://bitbucket.org/pypy/pypy/changeset/bee473720d24/
Log: Eh, I don't know how I missed that __kwdefaults__ could simply be a
moduledict
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -387,24 +387,18 @@
else:
if not space.isinstance_w(w_new, space.w_dict):
raise oefmt(space.w_TypeError, "__kwdefaults__ must be a dict")
- w_instance = self.init_kwdefaults_dict()
- w_instance.setdict(space, w_new)
- self.w_kw_defs = w_instance.getdict(space)
+ self.w_kw_defs = w_new
def fdel_func_kwdefaults(self, space):
self.w_kw_defs = None
- def init_kwdefaults_dict(self, kw_defs_w=[]):
- # use the mapdict logic to get at least not-too-bad JIT code
- # from function calls with default values of kwonly arguments
+ def init_kwdefaults_dict(self, kw_defs_w):
+ # use the moduledict logic to get normally-constant entries
space = self.space
- w_class = space.fromcache(KwDefsClassCache).w_class
- w_instance = space.call_function(w_class)
+ w_dict = space.newdict(module=True)
for w_name, w_value in kw_defs_w:
- attr = space.unicode_w(w_name).encode('utf-8')
- w_instance.setdictvalue(space, attr, w_value)
- self.w_kw_defs = w_instance.getdict(space)
- return w_instance
+ space.setitem(w_dict, w_name, w_value)
+ self.w_kw_defs = w_dict
def fget_func_doc(self, space):
if self.w_doc is None:
@@ -705,12 +699,3 @@
else:
code = None
return isinstance(code, BuiltinCode)
-
-
-class KwDefsClassCache:
- def __init__(self, space):
- self.w_class = space.appexec([], """():
- class KwDefs:
- pass
- return KwDefs
- """)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit