# InstanceTrackerSet class

(Shortest import: `from brian2.core.tracking import InstanceTrackerSet)`

class brian2.core.tracking.InstanceTrackerSet(iterable=(), /)

  Bases: `set`

  A `set` of `weakref.ref` to all existing objects of a certain class.

  Should not normally be directly used.

  Methods

  `add`(value) | Adds a `weakref.ref` to the `value`
  `remove`(value) | Removes the `value` (which should be a weakref) if it is in the set

  Details

  add(value)

    Adds a `weakref.ref` to the `value`

  remove(value)

    Removes the `value` (which should be a weakref) if it is in the set

    Sometimes the value will have been removed from the set by `clear`, so we ignore `KeyError` in this case.