def test_repr_global(self):
# In func()/method(), repr() builtin cannot be copied to constant,
# because the call to __fat__.replace_consts(func.__code__, {'...': repr}) would
# load the local repr() function instead of the builtin repr()
# function.
self.config._copy_builtin_to_constant.add('repr')
self.check_dont_optimize("""
def repr(obj):
return 'local'
def func(obj):
return repr(obj)
""")
self.check_dont_optimize("""
class MyClass:
@staticmethod
def repr(obj):
return 'local'
def method(self, obj):
return repr(obj)
""")
评论列表
文章目录