Note that functions (built-in and user-defined) are pickled by “fully qualified” name reference, not by value. This means that only the function name is pickled, along with the name of the module the function is defined in. Neither the function’s code, nor any of its function attributes are pickled. Thus the defining module must be importable in the unpickling environment, and the module must contain the named object, otherwise an exception will be raised.
不,不会的。
cache.set()
调用应该会给出如下错误:为什么?在内部,Django使用Python的pickle库来序列化您试图存储在缓存中的值。当您想用
cache.get()
调用再次将其从缓存中拉出时,Django需要确切地知道如何重建缓存的值。由于不希望丢失信息或错误/不正确地重建缓存值,有几个restrictions可以对哪些类型的对象进行pickle。您会注意到只有这些类型的函数可以被pickle:关于酸洗功能的工作原理还有以下进一步的解释:
相关问题 更多 >
编程相关推荐