#一些无聊又有点儿意思的小测试#
从知乎推荐的神书《500 Lines or Less》发现一个小point,调用对象方法时,解释器做的两个步骤:
# The way we're used to seeing it:
result.append("hello")
# But this works the same:
append_result = result.append
append_result("hello")
突发奇想做一个小测试: 提前保存对象方法,可以节约多少时间
Test A:
Test Result:
Test B:
Test Result:
也许有一天处理大量的数据时,它可以带来一点提高效率的灵感??