MCPcopy Index your code
hub / github.com/RustPython/RustPython / memoize

Method memoize

Lib/pickle.py:502–522  ·  view source on GitHub ↗

Store an object in the memo.

(self, obj)

Source from the content-addressed store, hash-verified

500 self.framer.end_framing()
501
502 def memoize(self, obj):
503 """Store an object in the memo."""
504
505 # The Pickler memo is a dictionary mapping object ids to 2-tuples
506 # that contain the Unpickler memo key and the object being memoized.
507 # The memo key is written to the pickle and will become
508 # the key in the Unpickler's memo. The object is stored in the
509 # Pickler memo so that transient objects are kept alive during
510 # pickling.
511
512 # The use of the Unpickler memo length as the memo key is just a
513 # convention. The only requirement is that the memo values be unique.
514 # But there appears no advantage to any other scheme, and this
515 # scheme allows the Unpickler memo to be implemented as a plain (but
516 # growable) array, indexed by memo key.
517 if self.fast:
518 return
519 assert id(obj) not in self.memo
520 idx = len(self.memo)
521 self.write(self.put(idx))
522 self.memo[id(obj)] = idx, obj
523
524 # Return a PUT (BINPUT, LONG_BINPUT) opcode string, with argument i.
525 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 4

putMethod · 0.95
idFunction · 0.85
lenFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected