weakref.pxd 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from .object cimport PyObject
  2. cdef extern from "Python.h":
  3. bint PyWeakref_Check(object ob)
  4. # Return true if ob is either a reference or proxy object.
  5. bint PyWeakref_CheckRef(object ob)
  6. # Return true if ob is a reference object.
  7. bint PyWeakref_CheckProxy(ob)
  8. # Return true if *ob* is a proxy object.
  9. object PyWeakref_NewRef(object ob, object callback)
  10. # Return a weak reference object for the object ob. This will
  11. # always return a new reference, but is not guaranteed to create a
  12. # new object; an existing reference object may be returned. The
  13. # second parameter, callback, can be a callable object that
  14. # receives notification when ob is garbage collected; it should
  15. # accept a single parameter, which will be the weak reference
  16. # object itself. callback may also be None or NULL. If ob is not
  17. # a weakly-referencable object, or if callback is not callable,
  18. # None, or NULL, this will return NULL and raise TypeError.
  19. object PyWeakref_NewProxy(object ob, object callback)
  20. # Return a weak reference proxy object for the object ob. This
  21. # will always return a new reference, but is not guaranteed to
  22. # create a new object; an existing proxy object may be returned.
  23. # The second parameter, callback, can be a callable object that
  24. # receives notification when ob is garbage collected; it should
  25. # accept a single parameter, which will be the weak reference
  26. # object itself. callback may also be None or NULL. If ob is not
  27. # a weakly-referencable object, or if callback is not callable,
  28. # None, or NULL, this will return NULL and raise TypeError.
  29. PyObject* PyWeakref_GetObject(object ref) except NULL
  30. # Return the referenced object from a weak reference, ref. If the
  31. # referent is no longer live, returns None.
  32. PyObject* PyWeakref_GET_OBJECT(object ref)
  33. # Similar to PyWeakref_GetObject, but implemented as a macro that
  34. # does no error checking.