Ë
    Dü´jW	  ã                   ód   — d Z ddlZdej                  dej                  dedefd„Zded	edefd
„Zy)u…  The hot scoring kernel, shared by the pure-Python and compiled builds.

This module is ordinary Python with no third-party imports: it runs as-is on
PyPy and in pure-Python installs.  When a compiled wheel is built,
``_kernel.pxd`` supplies C type declarations for these same functions and
Cython compiles this file to native code â€” the ``.py`` stays the one and only
implementation.

Note: ``from __future__ import annotations`` is intentionally omitted to match
the modules mypyc compiles, which import from here.

``dot_packed`` reads the profile's parallel ``array('i')`` buffers rather than
its dense 65536-entry table.  Compiled, that is the difference between a gather
through a Python list and a C loop over two contiguous int32 buffers.  The
interpreter pays for it â€” ``array`` indexing boxes an int where a list returns
a cached one â€” which is the trade this build makes deliberately.
é    NÚidxÚvalsÚmodelÚreturnc                 ób   — d}t        | «      }t        |«      D ]  }||| |      ||   z  z  }Œ |S )a«  Return the dot product of a packed bigram profile with a model table.

    :param idx: ``array('i')`` of bigram indices, in first-encounter order.
        Deliberately *not* sorted --- do not add a binary search or an
        early exit over it.
    :param vals: ``array('i')`` of weights, parallel to *idx*.
    :param model: 65536-byte model lookup table.
    :returns: Sum of ``model[idx[k]] * vals[k]`` over all ``k``.
    r   )ÚlenÚrange)r   r   r   ÚdotÚnÚis         úM/root/workspace/ytshorts/venv/lib/python3.12/site-packages/chardet/_kernel.pyÚ
dot_packedr      sE   € ð €CÜˆC‹€AÜ�1‹Xò 'ˆØˆu�S˜‘V‰}˜t A™wÑ&Ñ&‰ð'à€Jó    ÚnonzeroÚfreqc                 óÄ   — t        j                   ddg«      t        | «      z  }t        | «      }t        |«      D ]  }|| |      ||<   Œ t        j                   d| «      |fS )ad  Return parallel ``array('i')`` index/value buffers for a dense profile.

    ``int32`` holds any weight a truncated input can produce: statistical
    scoring caps its input at 16384 bytes, so no weight exceeds ``255 * 16383``
    (about 4.2 million) against an int32 ceiling of 2.1 billion.  The bound is
    the caller's to keep --- see :class:`~chardet.models.BigramProfile`, which
    documents the input limit that makes it hold.

    :param nonzero: Bigram indices with non-zero weight.
    :param freq: Dense 65536-entry weight table.
    :returns: An ``(idx, vals)`` tuple of ``array('i')`` buffers.
    r   r   )Úarrayr   r	   )r   r   r   r   r   s        r   Úpack_profiler   '   sc   € ô �;‰;�s˜Q˜CÓ ¤3 w£<Ñ/€DÜˆG‹€AÜ�1‹Xò #ˆØ�w˜q‘zÑ"ˆˆQŠð#ä�;‰;�s˜GÓ$ dÐ*Ð*r   )Ú__doc__r   ÚbytesÚintr   ÚlistÚtupler   © r   r   ú<module>r      sR   ðñó$ ð�E—K‘Kð  u§{¡{ð ¸5ð ÀSó ð"+˜$ð + dð +¨uô +r   