title: Python and solve_ivp: output internal data from ode-function
body: <p>To solve a system of ODEs, I need internal calculations of past time steps, so I have to save these internal calculations. I cannot save every calculation because of dynamic time step size of the solver.
  The event function doesn't help me either, because events only receives (t, y) input, but my internal data is a function of (t,y), f(t, y).</p>
  <p>Is there an elegant solution to save internal parameters when the solver has calculated a solution and not an internal calculation?</p>
  <p>The Problem is a system of ordinary ODEs.</p>
  <p>dydt = f(y, P) with P = f(y, e) and  e = f(P(t), P(t-1))</p>
  <p>What I need is (I think) a simple way to save P in order to access the value of the last time step P(t-1), while P is not a sulution of integrating dydt.</p>