我正在使用python3.7和Django。我在读关于“吃角子老虎机”的书。显然,通过这样做,\ U插槽可以用来优化大量这些对象的内存分配。。。你知道吗
class MyClass(object):
__slots__ = ['name', 'identifier']
def __init__(self, name, identifier):
self.name = name
self.identifier = identifier
self.set_up()
我最明显的问题是,为什么我们不想对所有对象都这样做呢?使用插槽有缺点吗?你知道吗
Fluent PythonbyLuciano Ramalho列出了以下注意事项
相关问题 更多 >
编程相关推荐