test_fatoptimizer.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:fatoptimizer 作者: vstinner 项目源码 文件源码
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)
        """)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号