MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / memoize

Method memoize

tools/python-3.11.9-amd64/Lib/pickle.py:491–511  ·  view source on GitHub ↗

Store an object in the memo.

(self, obj)

Source from the content-addressed store, hash-verified

489 self.framer.end_framing()
490
491 def memoize(self, obj):
492 """Store an object in the memo."""
493
494 # The Pickler memo is a dictionary mapping object ids to 2-tuples
495 # that contain the Unpickler memo key and the object being memoized.
496 # The memo key is written to the pickle and will become
497 # the key in the Unpickler's memo. The object is stored in the
498 # Pickler memo so that transient objects are kept alive during
499 # pickling.
500
501 # The use of the Unpickler memo length as the memo key is just a
502 # convention. The only requirement is that the memo values be unique.
503 # But there appears no advantage to any other scheme, and this
504 # scheme allows the Unpickler memo to be implemented as a plain (but
505 # growable) array, indexed by memo key.
506 if self.fast:
507 return
508 assert id(obj) not in self.memo
509 idx = len(self.memo)
510 self.write(self.put(idx))
511 self.memo[id(obj)] = idx, obj
512
513 # Return a PUT (BINPUT, LONG_BINPUT) opcode string, with argument i.
514 def put(self, idx):

Callers 10

save_reduceMethod · 0.95
save_bytesMethod · 0.95
save_bytearrayMethod · 0.95
save_strMethod · 0.95
save_tupleMethod · 0.95
save_listMethod · 0.95
save_dictMethod · 0.95
save_setMethod · 0.95
save_frozensetMethod · 0.95
save_globalMethod · 0.95

Calls 3

putMethod · 0.95
idFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected