DictView#
- class einspect.views.view_dict.DictView(obj, ref=True)#
- clear() None. Remove all items from D. #
- drop()#
Drop all references to the base object.
- Return type:
Notes
This is useful for when you want to drop the reference to the base object, but still want to access the view.
- gc_may_be_tracked()#
Return True if the object may be tracked by the GC in the future, or already is.
- Return type:
- get(k[, d]) D[k] if k in D, else d. d defaults to None. #
- info(types=True, arr_max=64)#
Return a formatted info string of the view struct.
- is_gc()#
Returns True if the object implements the Garbage Collector protocol.
If True, a PyGC_HEAD struct will precede the object struct in memory.
- Return type:
- items() a set-like object providing a view on D's items #
- keys() a set-like object providing a view on D's keys #
- move_from(other)#
Moves data at other Viewable to this View.
- move_to(dst, start=8)#
Copy the object to another view’s location.
- pop(k[, d]) v, remove specified key and return the corresponding value. #
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair #
as a 2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- swap(other)#
Swaps data at other Viewable with this View.
- unsafe()#
Context manager to enter an unsafe context.
- Return type:
ContextManager
[Self
]
Examples
>>> from einspect import view >>> v = view(100) >>> with v.unsafe(): >>> v.size += 1
>>> with view(100).unsafe() as v: >>> v.size -= 1
- update([E, ]**F) None. Update D from mapping/iterable E and F. #
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- values() an object providing a view on D's values #
- property base: _T#
Returns the base object of the view.
Requires either the View to be created with (ref=True) or the object to support weakrefs.
Notes
If neither ref nor weakref are available, and called within an unsafe context, returns an object via memory address cast. The result of the cast is undefined behavior, and could cause a segmentation fault.
- Returns:
The base object of the view.
- Raises:
AttributeError – If ref=False and base does not support weakrefs.
MovedError – If weak-ref of base is garbage collected.