o
    )i                     @   s`   d Z ddlmZ ddlmZ defddZdedd	fd
dZedefddZde	fddZ
d	S )z"Global configuration for XGrammar.    )contextmanager   )_corereturnc                   C   
   t j S )a  Get the maximum allowed recursion depth. The depth is shared per process.

    The maximum recursion depth is determined in the following order:

    1. Manually set via :py:func:`set_max_recursion_depth`
    2. ``XGRAMMAR_MAX_RECURSION_DEPTH`` environment variable (if set and is a valid integer <= 1,000,000)
    3. Default value of 10,000

    Returns
    -------
    max_recursion_depth : int
        The maximum allowed recursion depth.
    )r   configget_max_recursion_depth r	   r	   L/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/xgrammar/config.pyr      s   
r   max_recursion_depthNc                 C   s   t j|  dS )zSet the maximum allowed recursion depth. The depth is shared per process. This method is
    thread-safe.

    Parameters
    ----------
    max_recursion_depth : int
        The maximum allowed recursion depth.
    N)r   r   set_max_recursion_depth)r   r	   r	   r
   r      s   	r   
temp_depthc                 c   s0    t  }t|  z
dV  W t| dS t| w )zA context manager for temporarily setting recursion depth.

    Examples
    --------
    >>> with recursion_depth(1000):
    ...     # recursion depth is 1000 here
    ...     pass
    >>> # recursion depth is restored to original value
    N)r   r   )r   
prev_depthr	   r	   r
   r   %   s   c                   C   r   )zGet the serialization version number. The current version is "v4".

    Returns
    -------
    serialization_version : str
        The serialization version number.
    )r   r   get_serialization_versionr	   r	   r	   r
   r   8   s   
r   )__doc__
contextlibr   baser   intr   r   r   strr   r	   r	   r	   r
   <module>   s    