Your IP : 3.145.78.203


Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/random.cpython-312.opt-1.pyc

�

�Q�f{���^�dZddlmZddlmZmZm	Z
mZm
ZddlmZmZmZmZddlmZmZmZddlmZmZ m!Z"ddl#m$Z%ddl&m'Z(dd	l)m*Z+dd
l,m-Z.m/Z0ddl1m1Z2ddl#Z3ddl4Z4	dd
l5m6Z7gd�Z:ded�zed�zZ;ed�Z<ded�zZ=dZ>de>zZ?dZ@Gd�de4j��ZAGd�deA�ZBeA�ZCeCj�ZDeCj�ZEeCj�ZFeCj�ZGeCj�ZHeCj�ZIeCj�ZJeCj�ZKeCj�ZLeCj�ZMeCj�ZNeCj�ZOeCj�ZPeCj�ZQeCj�ZReCj�ZSeCj�ZTeCj�ZUeCj�ZVeCj�ZWeCj�ZXeCj�ZYeCj�ZZeCj�Z[d�Z\d!d�Z]e^e3d�re3j�eCj���e`d k(re]�yy#e8$r
dd
l9m6Z7Y���wxYw)"aERandom variable generators.

    bytes
    -----
           uniform bytes (values between 0 and 255)

    integers
    --------
           uniform within range

    sequences
    ---------
           pick random element
           pick random sample
           pick weighted random sample
           generate random permutation

    distributions on the real line:
    ------------------------------
           uniform
           triangular
           normal (Gaussian)
           lognormal
           negative exponential
           gamma
           beta
           pareto
           Weibull

    distributions on the circle (angles 0 to 2pi)
    ---------------------------------------------
           circular uniform
           von Mises

    discrete distributions
    ----------------------
           binomial


General notes on the underlying Mersenne Twister core generator:

* The period is 2**19937-1.
* It is one of the most extensively tested generators in existence.
* The random() method is implemented in C, executes in a single Python step,
  and is, therefore, threadsafe.

�)�warn)�log�exp�pi�e�ceil)�sqrt�acos�cos�sin)�tau�floor�isfinite)�lgamma�fabs�log2)�urandom)�Sequence)�index)�
accumulate�repeat)�bisectN)�sha512)�Random�SystemRandom�betavariate�binomialvariate�choice�choices�expovariate�gammavariate�gauss�getrandbits�getstate�lognormvariate�
normalvariate�
paretovariate�	randbytes�randint�random�	randrange�sample�seed�setstate�shuffle�
triangular�uniform�vonmisesvariate�weibullvariate�g��@�@��?�@�5��c���eZdZdZdZd$d�Zd%�fd�	Z�fd�Z�fd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
ezfd�Ze
Zd�Zdefd�Zd�Zd�Zd�Zdd�d�Zd$dd
d�d�Zd�Zd&d�Zd'd�Zd'd�Zd�Zd(d�Zd�Zd�Z d �Z!d!�Z"d"�Z#d)d#�Z$�xZ%S)*ra�Random number generator base class used by bound module functions.

    Used to instantiate instances of Random to get generators that don't
    share state.

    Class Random can also be subclassed if you want to use a different basic
    generator of your own devising: in that case, override the following
    methods:  random(), seed(), getstate(), and setstate().
    Optionally, implement a getrandbits() method so that randrange()
    can cover arbitrarily large ranges.

    �Nc�4�|j|�d|_y)zeInitialize an instance.

        Optional argument x controls seeding, as for Random.seed().
        N)r-�
gauss_next)�self�xs  �-/opt/alt/python312/lib64/python3.12/random.py�__init__zRandom.__init__~s��	
�	�	�!�����c	���|dk(r�t|ttf�rpt|t�r|jd�n|}|rt	|d�dznd}tt|�D]
}d|z|zdz}�|t
|�z}|dk(rdn|}n�|d	k(rkt|tttf�rPt|t�r|j�}tj|t|�j�z�}n:t|td
�tttttf�std��t �|�E|�d
|_y
)a\Initialize internal state from a seed.

        The only supported seed types are None, int, float,
        str, bytes, and bytearray.

        None or no argument seeds from current time or from an operating
        system specific randomness source if available.

        If *a* is an int, all bits are used.

        For version 2 (the default), all of the bits are used if *a* is a str,
        bytes, or bytearray.  For version 1 (provided for reproducing random
        sequences from older versions of Python), the algorithm for str and
        bytes generates a narrower range of seeds.

        r;zlatin-1r�iCBl����������r:NzOThe only supported seed types are: None,
int, float, str, bytes, and bytearray.)�
isinstance�str�bytes�decode�ord�map�len�	bytearray�encode�int�
from_bytes�_sha512�digest�type�float�	TypeError�superr-r?)r@�a�versionrA�c�	__class__s     �rBr-zRandom.seed�s���$�a�<�J�q�3��,�7�'1�!�U�';�����#��A�"#��A�a�D�	�Q���A���a�[����k�Q�&�*<�<��!�
��Q��K�A��2�g��1�A�
��\�j��S�%��,C�D��!�S�!��H�H�J�����q�7�1�:�#4�#4�#6�6�7�A��A��T�
�C���U�I�N�O��E�F�
F�	���Q����rDc�N��|jt�|�	�|jfS)z9Return internal state; can be passed to setstate() later.)�VERSIONrYr$r?)r@r]s �rBr$zRandom.getstate�s ����|�|�U�W�-�/����@�@rDc���|d}|dk(r|\}}|_t�|�	|�y|dk(r.|\}}|_	td�|D��}t�|�	|�yt	d|�d|j����#t$r}t
|�d}~wwxYw)z:Restore internal state from object returned by getstate().rr=r:c3�&K�|]	}|dz���y�w)lN�)�.0rAs  rB�	<genexpr>z"Random.setstate.<locals>.<genexpr>�s����%K�]��a�7�m�]�s�Nzstate with version z( passed to Random.setstate() of version )r?rYr.�tuple�
ValueErrorrXr_)r@�stater[�
internalstaterr]s     �rBr.zRandom.setstate�s������(���a�<�6;�3�G�]�D�O��G��]�+�
��\�6;�3�G�]�D�O�

'� %�%K�]�%K� K�
�
�G��]�+��%�t�|�|�5�6�
6��	�
'��Q�&��
'�s�A5�5	B
�>B�B
c�"�|j�S�N)r$�r@s rB�__getstate__zRandom.__getstate__�s���}�}��rDc�&�|j|�yrj)r.)r@rgs  rB�__setstate__zRandom.__setstate__�s���
�
�e�rDc�<�|jd|j�fS)Nrb)r]r$rks rB�
__reduce__zRandom.__reduce__�s���~�~�r�4�=�=�?�2�2rDc���|jD]T}d|jvryd|jvr|j|_yd|jvs�C|j|_yy)aControl how subclasses generate random integers.

        The algorithm a subclass can use depends on the random() and/or
        getrandbits() implementation available to it and determines
        whether it can generate random integers from arbitrarily large
        ranges.
        �
_randbelowr#r*N)�__mro__�__dict__�_randbelow_with_getrandbitsrr�_randbelow_without_getrandbits)�cls�kwargsr\s   rB�__init_subclass__zRandom.__init_subclass__�sY�����A��q�z�z�)����
�
�*�!$�!@�!@�����1�:�:�%�!$�!C�!C����rDc�t�|j}|j�}||�}||k\r||�}||k\r�|S)z;Return a random int in the range [0,n).  Defined for n > 0.)r#�
bit_length)r@�nr#�k�rs     rBruz"Random._randbelow_with_getrandbits�sA���&�&��
�L�L�N����N���1�f��A��A��1�f��rDr;c���|j}||k\rtd�t|�|z�S||z}||z
|z}|�}||k\r
|�}||k\r�
t||z�|zS)z�Return a random int in the range [0,n).  Defined for n > 0.

        The implementation does not use getrandbits, but only random.
        z�Underlying random() generator does not supply 
enough bits to choose from a population range this large.
To remove the range limitation, add a getrandbits() method.)r*�_warn�_floor)r@r|�maxsizer*�rem�limitr~s       rBrvz%Random._randbelow_without_getrandbits�s��������<��N�
O��&�(�Q�,�'�'���k���3��'�)���H���5�j���A��5�j��a�'�k�"�Q�&�&rDc�J�|j|dz�j|d�S)�Generate n random bytes.��little)r#�to_bytes�r@r|s  rBr(zRandom.randbytess$������A��&�/�/��8�<�<rDc	���t|�}|�4|turtd��|dkDr|j|�St	d��t|�}||z
}t|�}|dk(r+|dkDr||j|�zSt	d|�d|�d���|dkDr||zdz
|z}n|dkr||zdz|z}nt	d��|dkrt	d|�d|�d|�d���|||j|�zzS)	z�Choose a random item from range(stop) or range(start, stop[, step]).

        Roughly equivalent to ``choice(range(start, stop, step))`` but
        supports arbitrarily large ranges and is optimized for common cases.

        z Missing a non-None stop argumentrzempty range for randrange()r;zempty range in randrange(z, �)zzero step for randrange())�_index�_ONErXrrrf)	r@�start�stop�step�istart�istop�width�istepr|s	         rBr+zRandom.randrange#s'�������<��4��� B�C�C���z����v�.�.��:�;�;��t��������t����A�:��q�y������ 6�6�6��8���r�$��q�I�J�J��1�9�����"�u�,�A�
�Q�Y�����"�u�,�A��8�9�9���6��8���r�$��r�$��q�Q�R�R������� 2�2�2�2rDc�,�|j||dz�S)zJReturn random integer in range [a, b], including both end points.
        r;)r+�r@rZ�bs   rBr)zRandom.randintLs���~�~�a��1��%�%rDc�h�t|�std��||jt|��S)z2Choose a random element from a non-empty sequence.z$Cannot choose from an empty sequence)rO�
IndexErrorrr)r@�seqs  rBrz
Random.choiceUs/��
�3�x��C�D�D��4�?�?�3�s�8�,�-�-rDc��|j}ttdt|���D]}||dz�}||||c||<||<� y)z)Shuffle list x in place, and return None.r;N)rr�reversed�rangerO)r@rA�	randbelow�i�js     rBr/zRandom.shuffle^sP���O�O�	��%��3�q�6�*�+�A��!�a�%� �A��1��q��t�J�A�a�D�!�A�$�,rD)�countsc�~�t|t�std��t|�}|��t	t|��}t|�|k7rt
d��|j�}t|t�std��|dkrt
d��|jt|�|��}t}|D�	cgc]}	||||	���c}	S|j}
d|cxkr|kst
d��t
d��dg|z}d	}|d
kDr|dtt|dzd��zz
}||kr>t	|�}
t|�D]#}|
||z
�}|
|||<|
||z
d
z
|
|<�%|St�}|j }t|�D]+}|
|�}||vr
|
|�}||vr�
||�||||<�-|Scc}	w)afChooses k unique random elements from a population sequence.

        Returns a new list containing elements from the population while
        leaving the original population unchanged.  The resulting list is
        in selection order so that all sub-slices will also be valid random
        samples.  This allows raffle winners (the sample) to be partitioned
        into grand prize and second place winners (the subslices).

        Members of the population need not be hashable or unique.  If the
        population contains repeats, then each occurrence is a possible
        selection in the sample.

        Repeated elements can be specified one at a time or with the optional
        counts parameter.  For example:

            sample(['red', 'blue'], counts=[4, 2], k=5)

        is equivalent to:

            sample(['red', 'red', 'red', 'red', 'blue', 'blue'], k=5)

        To choose a sample from a range of integers, use range() for the
        population argument.  This is especially fast and space efficient
        for sampling from a large population:

            sample(range(10000000), 60)

        zAPopulation must be a sequence.  For dicts or sets, use sorted(d).Nz2The number of counts does not match the populationzCounts must be integersrz)Total of counts must be greater than zero)r}z,Sample larger than population or is negative��r4r=r;)rI�	_SequencerXrO�list�_accumulaterf�poprRr,r��_bisectrr�_ceil�_log�set�add)r@�
populationr}r�r|�
cum_counts�total�
selectionsr�sr��result�setsize�poolr�r��selected�selected_adds                  rBr,z
Random.samplegs���j�*�i�0��@�A�
A��
�O�����k�&�1�2�J��:��!�#� �!U�V�V��N�N�$�E��e�S�)�� 9�:�:���z� �!L�M�M����U�5�\�Q��7�J��F�?I�J�z�!�J�v�j�!�4�5�z�J�J��O�O�	��A�{��{��K�L�L���K�L�L���!������q�5��q�E�$�q�1�u�a�.�1�1�1�G���<��
�#�D��1�X���a�!�e�$�� ��G��q�	��q�1�u�q�y�/��Q����
��u�H�#�<�<�L��1�X���a�L���8�m�!�!��A��8�m��Q��&�q�M��q�	���
��3Ks�7F:)�cum_weightsr}c
�\�|j}t|�}|�N|�6t}|dz
}td|�D�cgc]}|||�|z���c}S	t	t|��}n
|�t
d��t|�|k7rtd��|ddz}	|	dkrtd��t|	�std��t}
|d	z
}td|�D�cgc]}||
||�|	zd
|���c}Scc}w#t$r#t|t�s�|}t
d|���d�wxYwcc}w)z�Return a k sized list of population elements chosen with replacement.

        If the relative weights or cumulative weights are not specified,
        the selections are made with equal probability.

        N�z4The number of choices must be a keyword argument: k=z2Cannot specify both weights and cumulative weightsz3The number of weights does not match the populationrGz*Total of weights must be greater than zerozTotal of weights must be finiter;r)r*rOr��_repeatr�r�rXrIrRrf�	_isfiniter�)r@r��weightsr�r}r*r|rr�r�r�his            rBrzRandom.choices�sf�������
�O���������S���AH��q�AQ�R�AQ�A�
�5���A��#6�7�AQ�R�R�
�"�;�w�#7�8���
 ��P�Q�Q��{��q� ��R�S�S��B��#�%���C�<��I�J�J�����>�?�?���
��U�� ��q�)�+�)�A��6�+�v�x�%�/?��B�G�H�)�+�	+��+S���
�!�'�3�/�����K���M����	
��$+s�C5�C:�D)�:,D&c�4�|||z
|j�zzS)z�Get a random number in the range [a, b) or [a, b] depending on rounding.

        The mean (expected value) and variance of the random variable are:

            E[X] = (a + b) / 2
            Var[X] = (b - a) ** 2 / 12

        �r*r�s   rBr1zRandom.uniform�s���A��E�T�[�[�]�*�*�*rDc��|j�}	|�dn
||z
||z
z}||kDrd|z
}d|z
}||}}|||z
t||z�zzS#t$r|cYSwxYw)a�Triangular distribution.

        Continuous distribution bounded by given lower and upper limits,
        and having a given mode value in-between.

        http://en.wikipedia.org/wiki/Triangular_distribution

        The mean (expected value) and variance of the random variable are:

            E[X] = (low + high + mode) / 3
            Var[X] = (low**2 + high**2 + mode**2 - low*high - low*mode - high*mode) / 18

        ��?r7)r*�ZeroDivisionError�_sqrt)r@�low�high�mode�ur\s      rBr0zRandom.triangular�s���
�K�K�M��	��|��$��*����)D�A�
�q�5��a��A��a��A��c��C��d�S�j�E�!�a�%�L�0�0�0��
!�	��J�	�s�A�A�Ac��|j}	|�}d|�z
}t|dz
z|z}||zdz}|t|�krn�9|||zzS)z\Normal distribution.

        mu is the mean, and sigma is the standard deviation.

        r7r�r6)r*�
NV_MAGICCONSTr�)r@�mu�sigmar*�u1�u2�z�zzs        rBr&zRandom.normalvariatesg���������B��v�x��B���c��*�R�/�A��Q����B��d�2�h�Y���
��A��I�~�rDc���|j}|j}d|_|�N|�tz}tdt	d|�z
�z�}t|�|z}t
|�|z|_|||zzS)z�Gaussian distribution.

        mu is the mean, and sigma is the standard deviation.  This is
        slightly faster than the normalvariate() function.

        Not thread-safe without a lock around calls.

        Ng�r7)r*r?�TWOPIr�r��_cos�_sin)r@r�r�r*r��x2pi�g2rads       rBr"zRandom.gauss'st��6�����O�O������9��8�e�#�D��$��c�F�H�n�!5�5�6�E��T�
�U�"�A�"�4�j�5�0�D�O��A��I�~�rDc�8�t|j||��S)z�Log normal distribution.

        If you take the natural logarithm of this distribution, you'll get a
        normal distribution with mean mu and standard deviation sigma.
        mu can have any value, and sigma must be greater than zero.

        )�_expr&)r@r�r�s   rBr%zRandom.lognormvariateMs���D�&�&�r�5�1�2�2rDc�B�td|j�z
�|zS)a�Exponential distribution.

        lambd is 1.0 divided by the desired mean.  It should be
        nonzero.  (The parameter would be called "lambda", but that is
        a reserved word in Python.)  Returned values range from 0 to
        positive infinity if lambd is positive, and from negative
        infinity to 0 if lambd is negative.

        The mean (expected value) and variance of the random variable are:

            E[X] = 1 / lambd
            Var[X] = 1 / lambd ** 2

        r7)r�r*)r@�lambds  rBr zRandom.expovariateWs"��$�S�4�;�;�=�(�)�)�E�1�1rDc��|j}|dkrt|�zSd|z}|td||zz�z}	|�}tt|z�}|||zz}|�}	|	d||zz
ks|	d|z
t|�zkrn�Id|z}
|
|zd|
|zzz}|�}|dkDr|t
|�ztz}
|
S|t
|�z
tz}
|
S)aFCircular data distribution.

        mu is the mean angle, expressed in radians between 0 and 2*pi, and
        kappa is the concentration parameter, which must be greater than or
        equal to zero.  If kappa is equal to zero, this distribution reduces
        to a uniform random angle over the range 0 to 2*pi.

        g���ư>r�r7)r*r�r�r��_pir��_acos)r@r��kappar*r�r~r�r��dr��q�f�u3�thetas              rBr2zRandom.vonmisesvariateks��� �����D�=��6�8�#�#��%�K��
��c�A��E�k�"�"�����B��S�2�X��A��Q��U��A���B��C�!�a�%�K��2�#��'�T�!�W�)<�#<���
�!�G��
��U�s�Q��U�{�#��
�X��
��8��%��(�]�e�+�E����%��(�]�e�+�E��rDc��|dks|dkrtd��|j}|dkDr�td|zdz
�}|tz
}||z}	|�}d|cxkrdksn�d|�z
}t	|d|z
z�|z}	|t|	�z}
||z|z}|||	zz|
z
}|tzd|zz
dk\s|t	|�k\r|
|zS�z|dk(rt	d|�z
�|zS	|�}
t|ztz}||
z}|dkr	|d|zz}
nt	||z
|z�}
|�}|dkDr||
|dz
zkr	|
|zS|t|
�kr	|
|zS�o)a�Gamma distribution.  Not the gamma function!

        Conditions on the parameters are alpha > 0 and beta > 0.

        The probability distribution function is:

                    x ** (alpha - 1) * math.exp(-x / beta)
          pdf(x) =  --------------------------------------
                      math.gamma(alpha) * beta ** alpha

        The mean (expected value) and variance of the random variable are:

            E[X] = alpha * beta
            Var[X] = alpha * beta ** 2

        r�z*gammavariate: alpha and beta must be > 0.0r7r5gH�����z>g�P���?r8)rfr*r��LOG4r�r��
SG_MAGICCONST�_e)r@�alpha�betar*�ainv�bbb�cccr�r��vrAr�r~r�r��ps                rBr!zRandom.gammavariate�s���(�C�<�4�3�;��I�J�J������3�;���u��s�*�+�D��$�,�C��$�,�C���X���b�,�9�,���6�8�^����s�R�x��)�D�0���D��G�O����G�b�L���#��'�M�A�%���}�$�s�Q�w�.�#�5��d�1�g���t�8�O���c�\���v�x��(�(�4�/�/�
��H���%�Z�2�%����E����8��c�E�k�*�A��q�1�u��o�.�.�A��X���s�7��Q�5�3�;�/�/���t�8�O��4���8�^���t�8�O�rDc�\�|j|d�}|r|||j|d�zzSy)aQBeta distribution.

        Conditions on the parameters are alpha > 0 and beta > 0.
        Returned values range between 0 and 1.

        The mean (expected value) and variance of the random variable are:

            E[X] = alpha / (alpha + beta)
            Var[X] = alpha * beta / ((alpha + beta)**2 * (alpha + beta + 1))

        r7r�)r!)r@r�r��ys    rBrzRandom.betavariate�s9��6
���e�S�)�����D�-�-�d�C�8�8�9�9�rDc�8�d|j�z
}|d|zzS)z3Pareto distribution.  alpha is the shape parameter.r7g�r�)r@r�r�s   rBr'zRandom.paretovariate�s#��
�$�+�+�-����T�E�\�"�"rDc�R�d|j�z
}|t|�d|zzzS)zfWeibull distribution.

        alpha is the scale parameter and beta is the shape parameter.

        r7)r*r�)r@r�r�r�s    rBr3zRandom.weibullvariates.��
�$�+�+�-�����a���c�D�j�1�1�1rDc���|dkrtd��|dks|dk\r|dk(ry|dk(r|Std��|j}|dk(rt|�|k�S|dkDr||j|d|z
�z
S||zdkrFdx}}t	d|z
�}|s|S	|tt	|��|z�dzz
}||kDr|S|dz
}�/d
}t
||zd|z
z�}dd|zz}	d
d|	zzd|zz}
||zdz}dd|	zz
}	|�}|dz}dt|�z
}
td|
z|
z|	z|z|z�}|dks||kDr�@|�}|
dk\r||kr|S|sOdd|	zz|z}t|d|z
z�}t|dz|z�}t|dz�t||z
dz�z}d	}||
|
|
zz|	zzz}t|�t|dz�z
t||z
dz�z
|z
zzkr|S��)a�Binomial random variable.

        Gives the number of successes for *n* independent trials
        with the probability of success in each trial being *p*:

            sum(random() < p for i in range(n))

        Returns an integer in the range:   0 <= X <= n

        The mean (expected value) and variance of the random variable are:

            E[X] = n * p
            Var[x] = n * p * (1 - p)

        rzn must be non-negativer�r7z&p must be in the range 0.0 <= p <= 1.0r;r�g$@TFgffffff�?g=
ףp=@gE���JY��ga��+e�?�{�G�z�?gq=
ףp�?g������@r5g�Q���?g�p=
ף@gffffff@)
rfr*r�r�_log2r�r��_fabsr��_lgamma)r@r|r�r*rAr�r\�setup_complete�spqr�rZ�vrr��usr}r�r��lpq�m�hs                    rBrzRandom.binomialvariates{��"
�q�5��5�6�6���8�q�C�x��C�x���C�x����E�F�F�����
��6��&�(�Q�,�'�'�
�s�7��t�+�+�A�s�Q�w�7�7�7��q�5�4�<��I�A���c�A�g��A������V�E�&�(�O�a�/�0�1�4�4���q�5��H��Q���	����A��E�S�1�W�%�&���4�#�:����f�q�j� �4�!�8�+��
��E�C�K��
�C�!�G�^�����A�
��H�A��u�Q�x��B���a��"��q�(�A�-��1�2�A��1�u��A�����A��T�z�a�2�g���
"���a���3�.���1��a��=�)���A��E�Q�;�'���A��E�N�W�Q��U�Q�Y�%7�7��!%��
��!�r�B�w�-�!�+�,�,�A��A�w�!�g�a�!�e�n�,�w�q�1�u�q�y�/A�A�Q��U�c�M�Q�Q���5rDrj)Nr:)r�r7N�r�r7)r7)r;r�)&�__name__�
__module__�__qualname__�__doc__r_rCr-r$r.rlrnrpryru�BPFrvrrr(r�r+r)rr/r,rr1r0r&r"r%r r2r!rr'r3r�
__classcell__)r]s@rBrrns������G��$�LA�6�B��3��(�9:�3��'�&-�J�=�%)�t�'3�R&�.�$�/3�]�~#+�t�q�#+�P	+�1�2�*$�L3�2�((�TC�J�@#�	2�VrDrc�6�eZdZdZd�Zd�Zd�Zd�Zd�ZexZ	Z
y)rz�Alternate random number generator using sources provided
    by the operating system (such as /dev/urandom on Unix or
    CryptGenRandom on Windows).

     Not available on all systems (see os.urandom() for details).

    c�R�tjtd��dz	tzS)z7Get the next random number in the range 0.0 <= X < 1.0.rFr=)rRrS�_urandom�	RECIP_BPFrks rBr*zSystemRandom.randomus�����x��{�+�q�0�I�=�=rDc��|dkrtd��|dzdz}tjt|��}||dz|z
z	S)z:getrandbits(k) -> x.  Generates an int with k random bits.rz#number of bits must be non-negativerFr�)rfrRrSr	)r@r}�numbytesrAs    rBr#zSystemRandom.getrandbitsysI���q�5��B�C�C���E�a�<���N�N�8�H�-�.���X��\�A�%�&�&rDc��t|�S)r�)r	r�s  rBr(zSystemRandom.randbytes�s����{�rDc��y)z<Stub method.  Not used for a system random number generator.Nrb�r@�args�kwdss   rBr-zSystemRandom.seed�s��rDc��td��)zAMethod should not be called for a system random number generator.z*System entropy source does not have state.)�NotImplementedErrorrs   rB�_notimplementedzSystemRandom._notimplemented�s��!�"N�O�OrDN)rrrrr*r#r(r-rr$r.rbrDrBrrls-���>�'���P�*�)�H�xrDrc�6�ddlm}m}ddlm}|�}td|�D�cgc]}||���	}}|�}	||�}
|||
�}t
|�}t|�}
t|	|z
d�d|�d|j�|���td|
|||
fz�ycc}w)Nr)�stdev�fmean)�perf_counterz.3fz sec, z times z"avg %g, stddev %g, min %g, max %g
)
�
statisticsrr�timerr��min�max�printr)r|�funcrr�meanr�t0r��data�t1�xbarr�r�r�s              rB�_test_generatorr$�s���/�!�	��B�!(��q�!1�2�!1�A�D�$�K�!1�D�2�	��B���:�D��$���E�

�d�)�C��t�9�D�	�R�"�W�S�M���s�'�$�-�-����
A�B�	�
/�4���T�2J�
J�K��3s�Bc�h�t|td�t|td�t|td�t|td�t|t
d�t|t
d�t|td�t|td�t|td�t|td�t|td	�t|td
�t|td�t|td�t|td
�t|td�t|td�t|td�y)Nrbr)�g333333�?)�dg�?)r�r7)皙�����?r7)r(r5)r�r7)g�������?r7)r7r7)r5r7)g4@r7)gi@r7)�@r))r�r7gUUUUUU�?)
r$r*r&r%r2rr!r"rr0)�Ns rB�_testr+�s����A�v�r�"��A�}�j�1��A�~�z�2��A��
�3��A��
�3��A���4��A�|�[�1��A�|�Z�0��A�|�Z�0��A�|�Z�0��A�|�Z�0��A�|�Z�0��A�|�Z�0��A�|�[�1��A�|�\�2��A�u�j�)��A�{�J�/��A�z�#8�9rD�fork)�after_in_child�__main__)i')ar�warningsrr��mathrr�rr�rr�rr�rr�r	r�r
r�rr�rr�r
r�rr�rr�rr�rr�rr��osrr	�_collections_abcrr��operatorrr��	itertoolsrr�rr�rr��_os�_random�_sha2rrT�ImportError�hashlib�__all__r�r�r�rr
r�rr�_instr-r*r1r0r)rr+r,r/rr&r%r r2r!r"rrr'r3r$r.r#r(r$r+�hasattr�register_at_forkrrbrDrB�<module>r>s���.�h#�L�L�G�G�E�E�@�@�"�2�$�B�$���*�'�
��:�D��J���s��+�
��C�y���d�3�i��
���
�#��I�	���w�W�^�^�w�|"*�6�"*�X	����z�z��	����
�-�-��
�
�
�
�
�-�-��	�����O�O�	�	����
�-�-��
�-�-���#�#�
��%�%�������'�'���!�!��
���������'�'���#�#�
��%�%���>�>���>�>�������O�O�	�L�":�0�3����C����
�
�3��z��	�G���}�*�)�)�*�s� H�H,�+H,

?>