
    *pjW	                     h    S r SSKrS\R                  S\R                  S\S\4S jrS\S	\S\4S
 jrg)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                 `    Sn[        U 5      n[        U5       H  nX2X      X   -  -  nM     U$ )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         K/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/chardet/_kernel.py
dot_packedr      s:     CCA1XSV}tw&& J    nonzerofreqc                     [         R                   " SS/5      [        U 5      -  n[        U 5      n[        U5       H  nXU      X$'   M     [         R                   " SU 5      U4$ )a@  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   '   sZ     ;;sQC 3w</DGA1Xqz" ;;sG$d**r   )__doc__r   bytesintr   listtupler    r   r   <module>r      sR   $ EKK u{{ 5 S "+$ +d +u +r   