INNER CODE UNIT · Python
_RMemory
briscverse/ryp · ryp.py:673
class _RMemory:
"""
A utility class for managing R's memory protection with Rf_protect() and
Rf_unprotect(). Based on the rpy2.rinterface_lib.memorymanagement.rmemory
context manager.
"""
def __init__(self: _RMemory, rlib: _cffi_backend.Lib) -> None:
self.rlib = rlib
self.count = 0
def __enter__(self: _RMemory) -> _RMemory:
return self
def protect(self: _RMemory,
robject: _cffi_backend._CDataBase) -> _cffi_backend._CDataBase:
robject = self.rlib.Rf_protect(robject)
self.count += 1
return robject