MCPcopy Index your code
hub / github.com/ZeroIntensity/pointers.py / to_ptr

Function to_ptr

src/pointers/object_pointer.py:70–89  ·  view source on GitHub ↗

Point to the underlying `PyObject`. Args: obj: Object to point to. Returns: Created pointer. Example: ```py ptr = to_ptr(1) # ptr now points to 1 something = 2 something_ptr = to_ptr(something) # points to 2, not "something" ``

(obj: Nullable[T])

Source from the content-addressed store, hash-verified

68
69@handle
70def to_ptr(obj: Nullable[T]) -> Pointer[T]:
71 """Point to the underlying `PyObject`.
72
73 Args:
74 obj: Object to point to.
75
76 Returns:
77 Created pointer.
78
79 Example:
80 ```py
81 ptr = to_ptr(1) # ptr now points to 1
82 something = 2
83 something_ptr = to_ptr(something) # points to 2, not "something"
84 ```
85 """
86 add_ref(obj)
87 ptr = Pointer.make_from(obj)
88 remove_ref(obj)
89 return ptr

Callers 6

_Function · 0.90
moveMethod · 0.85
__and__Method · 0.85
moveMethod · 0.85
_decay_paramsFunction · 0.85
wrappedFunction · 0.85

Calls 3

add_refFunction · 0.85
remove_refFunction · 0.85
make_fromMethod · 0.45

Tested by 1

_Function · 0.72