o
    ä¯ªg  ã                   @  s@   d dl mZ d dlZd dlZG dd„ dejƒZG dd„ dƒZdS )é    )ÚannotationsNc                   @  s0   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
S )ÚDlpackDeviceTypez3Integer enum for device type codes matching DLPack.é   é   é   é   é   é   é	   é
   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚCPUÚCUDAÚ
CPU_PINNEDÚOPENCLÚVULKANÚMETALÚVPIÚROCM© r   r   úV/var/www/html/chatdoc2/venv/lib/python3.10/site-packages/pyarrow/interchange/buffer.pyr      s    r   c                   @  sT   e Zd ZdZddd	d
„Zeddd„ƒZeddd„ƒZdd„ Zddd„Z	ddd„Z
dS )Ú_PyArrowBufferaY  
    Data in the buffer is guaranteed to be contiguous in memory.

    Note that there is no dtype attribute present, a buffer can be thought of
    as simply a block of memory. However, if the column that the buffer is
    attached to has a dtype that's supported by DLPack and ``__dlpack__`` is
    implemented, then that dtype information will be contained in the return
    value from ``__dlpack__``.

    This distinction is useful to support both data exchange via DLPack on a
    buffer and (b) dtypes like variable-length strings which do not have a
    fixed number of bytes per element.
    TÚxú	pa.BufferÚ
allow_copyÚboolÚreturnÚNonec                 C  s
   || _ dS )z)
        Handle PyArrow Buffers.
        N)Ú_x)Úselfr   r   r   r   r   Ú__init__4   s   
z_PyArrowBuffer.__init__Úintc                 C  ó   | j jS )z'
        Buffer size in bytes.
        )r!   Úsize©r"   r   r   r   Úbufsize:   ó   z_PyArrowBuffer.bufsizec                 C  r%   )z?
        Pointer to start of the buffer as an integer.
        )r!   Úaddressr'   r   r   r   ÚptrA   r)   z_PyArrowBuffer.ptrc                 C  s   t dƒ‚)a}  
        Produce DLPack capsule (see array API standard).

        Raises:
            - TypeError : if the buffer contains unsupported dtypes.
            - NotImplementedError : if DLPack support is not implemented

        Useful to have to connect to array libraries. Support optional because
        it's not completely trivial to implement for a Python-only library.
        Ú
__dlpack__)ÚNotImplementedErrorr'   r   r   r   r,   H   s   z_PyArrowBuffer.__dlpack__ú#tuple[DlpackDeviceType, int | None]c                 C  s   | j jr	tjdfS tdƒ‚)zÆ
        Device type and device ID for where the data in the buffer resides.
        Uses device type codes matching DLPack.
        Note: must be implemented even if ``__dlpack__`` is not.
        NÚ__dlpack_device__)r!   Úis_cpur   r   r-   r'   r   r   r   r/   U   s   
z _PyArrowBuffer.__dlpack_device__Ústrc                 C  s&   dt | j| j|  ¡ d jdœƒ d S )NzPyArrowBuffer(r   )r(   r+   Údeviceú))r1   r(   r+   r/   Únamer'   r   r   r   Ú__repr__`   s   ýÿÿøÿz_PyArrowBuffer.__repr__N)T)r   r   r   r   r   r    )r   r$   )r   r.   )r   r1   )r   r   r   r   r#   Úpropertyr(   r+   r,   r/   r5   r   r   r   r   r   %   s    
r   )Ú
__future__r   ÚenumÚpyarrowÚpaÚIntEnumr   r   r   r   r   r   Ú<module>   s
   