§
    q-Ph•  ã                  ó  — d dl mZ d dlZd dlmZ  ej        e¦  «        5  d dlmZ	 d dlm
Z
 ddd¦  «         n# 1 swxY w Y   er"d dlZd dlmZ ej        dk    rd dlmZ nd dlmZ g d¢Z G d	„ d
ej        ¦  «        Zdd„Zdd„Zdd„ZdS )é    )ÚannotationsN)ÚTYPE_CHECKING)ÚPyStringCacheHolder)ÚTracebackType)é   é   )ÚSelf)ÚStringCacheÚdisable_string_cacheÚenable_string_cacheÚusing_string_cachec                  ó"   — e Zd ZdZdd„Zdd„ZdS )r
   a¸  
    Context manager for enabling and disabling the global string cache.

    :class:`Categorical` columns created under the same global string cache have
    the same underlying physical value when string values are equal. This allows the
    columns to be concatenated or used in a join operation, for example.

    Notes
    -----
    Enabling the global string cache introduces some overhead.
    The amount of overhead depends on the number of categories in your data.
    It is advised to enable the global string cache only when strictly necessary.

    If `StringCache` calls are nested, the global string cache will only be disabled
    and cleared when the outermost context exits.

    Examples
    --------
    Construct two Series using the same global string cache.

    >>> with pl.StringCache():
    ...     s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical)
    ...     s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical)

    As both Series are constructed under the same global string cache,
    they can be concatenated.

    >>> pl.concat([s1, s2])
    shape: (6,)
    Series: 'color' [cat]
    [
            "red"
            "green"
            "red"
            "blue"
            "red"
            "green"
    ]

    The class can also be used as a function decorator, in which case the string cache
    is enabled during function execution, and disabled afterwards.

    >>> @pl.StringCache()
    ... def construct_categoricals() -> pl.Series:
    ...     s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical)
    ...     s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical)
    ...     return pl.concat([s1, s2])
    Úreturnr	   c                ó,   — t          ¦   «         | _        | S ©N)r   Ú_string_cache)Úselfs    úS/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/string_cache.pyÚ	__enter__zStringCache.__enter__N   s   € Ý0Ñ2Ô2ˆÔØˆó    Úexc_typeútype[BaseException] | NoneÚexc_valúBaseException | NoneÚexc_tbúTracebackType | NoneÚNonec                ó
   — | ` d S r   )r   )r   r   r   r   s       r   Ú__exit__zStringCache.__exit__R   s   € ð ÐÐÐr   N)r   r	   )r   r   r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r
   r
      sG   € € € € € ð/ð /ðbð ð ð ðð ð ð ð ð r   r
   r   r   c                 ó,   — t          j        ¦   «          dS )a¡  
    Enable the global string cache.

    :class:`Categorical` columns created under the same global string cache have
    the same underlying physical value when string values are equal. This allows the
    columns to be concatenated or used in a join operation, for example.

    See Also
    --------
    StringCache : Context manager for enabling and disabling the string cache.
    disable_string_cache : Function to disable the string cache.

    Notes
    -----
    Enabling the global string cache introduces some overhead.
    The amount of overhead depends on the number of categories in your data.
    It is advised to enable the global string cache only when strictly necessary.

    Consider using the :class:`StringCache` context manager for a more reliable way of
    enabling and disabling the string cache.

    Examples
    --------
    Construct two Series using the same global string cache.

    >>> pl.enable_string_cache()
    >>> s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical)
    >>> s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical)
    >>> pl.disable_string_cache()

    As both Series are constructed under the same global string cache,
    they can be concatenated.

    >>> pl.concat([s1, s2])
    shape: (6,)
    Series: 'color' [cat]
    [
            "red"
            "green"
            "red"
            "blue"
            "red"
            "green"
    ]
    N)Úplrr   r$   r   r   r   r   [   s   € õ\ ÔÑÔÐÐÐr   Úboolc                 ó(   — t          j        ¦   «         S )as  
    Disable and clear the global string cache.

    See Also
    --------
    enable_string_cache : Function to enable the string cache.
    StringCache : Context manager for enabling and disabling the string cache.

    Notes
    -----
    Consider using the :class:`StringCache` context manager for a more reliable way of
    enabling and disabling the string cache.

    When used in conjunction with the :class:`StringCache` context manager, the string
    cache will not be disabled until the context manager exits.

    Examples
    --------
    Construct two Series using the same global string cache.

    >>> pl.enable_string_cache()
    >>> s1 = pl.Series("color", ["red", "green", "red"], dtype=pl.Categorical)
    >>> s2 = pl.Series("color", ["blue", "red", "green"], dtype=pl.Categorical)
    >>> pl.disable_string_cache()

    As both Series are constructed under the same global string cache,
    they can be concatenated.

    >>> pl.concat([s1, s2])
    shape: (6,)
    Series: 'color' [cat]
    [
            "red"
            "green"
            "red"
            "blue"
            "red"
            "green"
    ]
    )r&   r   r$   r   r   r   r   Œ   s   € õR Ô#Ñ%Ô%Ð%r   c                 ó(   — t          j        ¦   «         S )z1Check whether the global string cache is enabled.)r&   r   r$   r   r   r   r   ¸   s   € åÔ!Ñ#Ô#Ð#r   )r   r   )r   r'   )Ú
__future__r   Ú
contextlibÚtypingr   ÚsuppressÚImportErrorÚpolars.polarsÚpolarsr&   r   ÚsysÚtypesr   Úversion_infor	   Útyping_extensionsÚ__all__ÚContextDecoratorr
   r   r   r   r$   r   r   ú<module>r7      s¢  ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  à€ZÔ˜Ñ%Ô%ð 2ð 2ØÐÐÐÐÐØ1Ð1Ð1Ð1Ð1Ð1ð2ð 2ð 2ñ 2ô 2ð 2ð 2ð 2ð 2ð 2ð 2øøøð 2ð 2ð 2ð 2ð ð +Ø€J€J€JØ#Ð#Ð#Ð#Ð#Ð#à
Ô˜7Ò"Ð"ØÐÐÐÐÐÐà*Ð*Ð*Ð*Ð*Ð*ðð ð €ð<ð <ð <ð <ð <*Ô-ñ <ô <ð <ð~.ð .ð .ð .ðb)&ð )&ð )&ð )&ðX$ð $ð $ð $ð $ð $s   ¡:º>Á>