Class LivePyObjectWrapper

All Implemented Interfaces:
LogOutputAppendable, LivenessReferent

public final class LivePyObjectWrapper extends ReferenceCountedLivenessReferent
Provides a mapping between Python refcount and Deephaven's liveness mechanism, allowing liveness scopes to manage the single strong reference that the PyObject instance represents. This way, as long as PyObjectRefCountedNode instances are managed correctly by their parent scope, the PyObject strong reference will be correctly released when the object is no longer used.

This class is experimental, and may be changed or moved in a future release to a new package.
See Also:
  • Constructor Details

    • LivePyObjectWrapper

      @ScriptApi public LivePyObjectWrapper(@NotNull @NotNull org.jpy.PyObject pythonObject)
      Constructs a PyObjectRefCountedNode instance by wrapping a PyObject. The caller should ensure that an appropriate liveness scope is open to retain this instance.
  • Method Details

    • destroy

      protected void destroy()
      Description copied from class: ReferenceCountedLivenessReferent
      Attempt to release (destructively when necessary) resources held by this object. This may render the object unusable for subsequent operations. Implementations should be sure to call super.destroy().

      This is intended to only ever be used as a side effect of decreasing the reference count to 0.

      Overrides:
      destroy in class ReferenceCountedLivenessReferent
    • getPythonObject

      @ScriptApi public org.jpy.PyObject getPythonObject()
      Returns the PyObject instance tracked by this object.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object