+
    i                         RR lt R tR# )printc                   a aaaa S'       g   R oMSR8X  d
   ^ .oV3R loS'       g   R oMSR8X  d
   ^ .oV3R loV VV3R lpV# )a  
Returns a wrapped copy of *f* that monitors evaluation by calling
*input* with every input (*args*, *kwargs*) passed to *f* and
*output* with every value returned from *f*. The default action
(specify using the special string value ``'print'``) is to print
inputs and outputs to stdout, along with the total evaluation
count::

    >>> from mpmath import *
    >>> mp.dps = 5; mp.pretty = False
    >>> diff(monitor(exp), 1)   # diff will eval f(x-h) and f(x+h)
    in  0 (mpf('0.99999999906867742538452148'),) {}
    out 0 mpf('2.7182818259274480055282064')
    in  1 (mpf('1.0000000009313225746154785'),) {}
    out 1 mpf('2.7182818309906424675501024')
    mpf('2.7182808')

To disable either the input or the output handler, you may
pass *None* as argument.

Custom input and output handlers may be used e.g. to store
results for later analysis::

    >>> mp.dps = 15
    >>> input = []
    >>> output = []
    >>> findroot(monitor(sin, input.append, output.append), 3.0)
    mpf('3.1415926535897932')
    >>> len(input)  # Count number of evaluations
    9
    >>> print(input[3]); print(output[3])
    ((mpf('3.1415076583334066'),), {})
    8.49952562843408e-5
    >>> print(input[4]); print(output[4])
    ((mpf('3.1415928201669122'),), {})
    -1.66577118985331e-7

c                     R # N vs   &p/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/mpmath/usertools.py<lambda>monitor.<locals>.<lambda>*   s    $    r   c                 v   < V w  r\        R S^ ,          : RV: RV: 24       S^ ;;,          ^,          uu&   R# )zin   Nr   )valueargskwargsincounts   &  r	   inputmonitor.<locals>.input-   s,     LDGAJJf=>AJ!OJr   c                     R # r   r   r   s   &r	   r
   r   2   s    4r   c                 f   < \        R S^ ,          : RV : 24       S^ ;;,          ^,          uu&   R# )zout r   Nr   )r   outcounts   &r	   outputmonitor.<locals>.output5   s$    !e45QK1Kr   c                  :   < S! W34       S! V / VB pS! V4       V# r   r   )r   r   r   fr   r   s   *, r	   f_monitoredmonitor.<locals>.f_monitored8   s(    tntvq	r   r   )r   r   r   r   r   r   s   fff @@r	   monitorr      sM    N 	'	#	 	7	3	
 r   c                .  a aaa SP                  R4      pRS9   d   SR S'       g	   S'       d3   \        S4      ^8X  d   S'       g   S^ ,          oVV 3R lpMVV V3R lpMS p^ RIHp V! 4       qd! 4       qu! 4       qV,
          p	V	R8  g	   V'       d   V	# \	        ^4       Fp  p
V! 4       pV! 4        V! 4        V! 4        V! 4        V! 4        V! 4        V! 4        V! 4        V! 4        V! 4        V! 4       p\        WV,
          ^
,          4      p	Kr  	  V	# )z
Returns time elapsed for evaluating ``f()``. Optionally arguments
may be passed to time the execution of ``f(*args, **kwargs)``.

If the first call is very quick, ``f`` is called
repeatedly and the best time is returned.
oncec                     < S! S 4      # r   r   )argr   s   r	   r
   timing.<locals>.<lambda>M   s	    #r   c                     < S! S / SB # r   r   )r   r   r   s   r	   r
   r$   O   s    4*6*r   )default_timerg?)getlentimeitr&   rangemin)r   r   r   r!   gclockt1r   t2tir#   s   fjl        @r	   timingr2   ?   s     ::fD6Nvt9>&q'CA*A-wB!#%'rU14x41X7 	
ACACACACAC7
aB

  Hr   N)r   r   )r   r2   r   r   r	   <module>r3      s   ;zr   