class_docstr: A generic wrapper for performing time rolling computations.
  
  This can be wrapped around any object which implements both an `update` and a `revert` method.
  Inputs to `update` are stored in a queue. Elements of the queue are popped when they are too
  old.
  
  Parameters
  ----------
  obj
      An object that implements both an `update` method and a `rolling `method.
  period
      A duration of time, expressed as a `datetime.timedelta`.
  
  Examples
  --------
  
  For instance, here is how you can compute a rolling average over a period of 3 days:
  
  >>> from river import stats, utils
  
  >>> X = {
  ...     dt.datetime(2019, 1, 1): 1,
  ...     dt.datetime(2019, 1, 2): 5,
  ...     dt.datetime(2019, 1, 3): 9,
  ...     dt.datetime(2019, 1, 4): 13
  ... }
  
  >>> rmean = utils.TimeRolling(stats.Mean(), period=dt.timedelta(days=3))
  >>> for t, x in X.items():
  ...     rmean.update(x, t=t)
  ...     print(rmean.get())
  1.0
  3.0
  5.0
  9.0
code: def update(self, *args, t: dt.datetime, **kwargs):
      self.obj.update(*args, **kwargs)
      i = bisect.bisect_left(self._timestamps, t)
      self._timestamps.insert(i, t)
      self._datum.insert(i, (args, kwargs))
  
      # There will only be events to revert if the new event if younger than the previously seen
      # youngest event
      if t > self._latest:
          self._latest = t
  
          i = 0
          for ti, (argsi, kwargsi) in zip(
              self._timestamps, self._datum
          ):
              if ti > t - self.period:
                  break
              self.obj.revert(*argsi, **kwargsi)
              i += 1
  
          # Remove expired events
          if i > 0:
              self._timestamps = self._timestamps[i:]
              self._datum = self._datum[i:]
  
imports: from __future__ import annotations
  import bisect
  import collections
  import datetime
  import typing
label_desc: Use image node_id 2 for calling the TimeRolling obj's underlying member method code with example usage: obj.update() without return types