MCPcopy Create free account
hub / github.com/ZeroIntensity/pointers.py / move

Method move

src/pointers/base_pointers.py:382–405  ·  view source on GitHub ↗
(
        self,
        data: Union[BasePointer[T], T],
        unsafe: bool = False,
    )

Source from the content-addressed store, hash-verified

380
381 @handle
382 def move(
383 self,
384 data: Union[BasePointer[T], T],
385 unsafe: bool = False,
386 ) -> None:
387 add_ref(data)
388 self.ensure_valid()
389 from .object_pointer import to_ptr
390
391 data_ptr = data if isinstance(data, BasePointer) else to_ptr(data)
392
393 if (sys.version_info.minor >= 11) and (gc.is_tracked(~data_ptr)):
394 remove_ref(data)
395 raise RuntimeError("allocation on tracked types is not supported on 3.11+")
396
397
398 ptr, byte_stream = self._make_stream_and_ptr(
399 sys.getsizeof(~data_ptr),
400 data_ptr.ensure(),
401 )
402
403 move_to_mem(ptr, byte_stream, unsafe=unsafe)
404 self.assigned = True
405 remove_ref(data)
406
407 @handle
408 def dereference(self) -> T:

Callers

nothing calls this directly

Calls 7

ensure_validMethod · 0.95
_make_stream_and_ptrMethod · 0.95
add_refFunction · 0.85
to_ptrFunction · 0.85
remove_refFunction · 0.85
move_to_memFunction · 0.85
ensureMethod · 0.45

Tested by

no test coverage detected