摘要:
""" 享元模式 将不可变(可共享)的属性与可变的属性分开 """ import random from enum import Enum TreeType = Enum('TreeType', 'apple_tree cherry_tree peach_tree') class Tree: poo 阅读全文
摘要:
""" 修饰器模式 """ import functools def memoize(fn): known = dict() @functools.wraps(fn) def memoizer(*args): if args not in known: known[args] = fn(*args) 阅读全文