Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 3.16.139.131
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_iterlen.pyc
�
?��cc@sdZddlZddlmZddlmZddlmZddlm	Z
dZd�Z	d	ejfd
��YZ
de
fd��YZd
e
fd��YZde
fd��YZde
fd��YZde
fd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZdefd ��YZd!e
fd"��YZd#e
fd$��YZd%efd&��YZd'efd(��YZd)efd*��YZd+ejfd,��YZd-�Z e!d.kre �ndS(/s� Test Iterator Length Transparency

Some functions or methods which accept general iterable arguments have
optional, more efficient code paths if they know how many items to expect.
For instance, map(func, iterable), will pre-allocate the exact amount of
space required whenever the iterable can report its length.

The desired invariant is:  len(it)==len(list(it)).

A complication is that an iterable and iterator can be the same object. To
maintain the invariant, an iterator needs to dynamically update its length.
For instance, an iterable such as xrange(10) always reports its length as ten,
but it=iter(xrange(10)) starts at ten, and then goes to nine after it.next().
Having this capability means that map() can ignore the distinction between
map(func, iterable) and map(func, iter(iterable)).

When the iterable is immutable, the implementation can straight-forwardly
report the original length minus the cumulative number of calls to next().
This is the case for tuples, xrange objects, and itertools.repeat().

Some containers become temporarily immutable during iteration.  This includes
dicts, sets, and collections.deque.  Their implementation is equally simple
though they need to permanently set their length to zero whenever there is
an attempt to iterate after a length mutation.

The situation slightly more involved whenever an object allows length mutation
during iteration.  Lists and sequence iterators are dynamically updatable.
So, if a list is extended during iteration, the iterator will continue through
the new items.  If it shrinks to a point before the most recent iteration,
then no further items are available and the length is reported at zero.

Reversed objects can also be wrapped around mutable objects; however, any
appends after the current position are ignored.  Any other approach leads
to confusion and possibly returning the same item more than once.

The iterators not listed above, such as enumerate and the other itertools,
are not length transparent because they have no way to distinguish between
iterables that report static length and iterators whose length changes with
each call (i.e. the difference between enumerate('abc') and
enumerate(iter('abc')).

i����N(ttest_support(trepeat(tdeque(tleni
cCsNyt|�SWn9tk
rIy|j�SWqJtk
rEt�qJXnXdS(N(t_lent	TypeErrort__length_hint__tAttributeError(tobj((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR4s

tTestInvariantWithoutMutationscBseZd�ZRS(cCs�|j}xAttdtd��D]&}|jt|�|�|j�q#W|jt|�d�|jt|j�|jt|�d�dS(Nii(	tittreversedtxrangetntassertEqualRtnexttassertRaisest
StopIteration(tselfR
ti((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyttest_invariantAs	 (t__name__t
__module__R(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR	?stTestTemporarilyImmutablecBseZd�ZRS(cCsz|j}|jt|�t�|j�|jt|�td�|j�|jt|j�|jt|�d�dS(Nii(R
RRR
RtmutateRtRuntimeError(RR
((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyttest_immutable_during_iterationLs	

(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRJst
TestRepeatcBseZd�Zd�ZRS(cCstdt�|_dS(N(RtNoneR
R
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pytsetUp\scCs|jtttd��dS(N(RRRRR(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyttest_no_len_for_infinite_repeat_s(RRRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRZs	t
TestXrangecBseZd�ZRS(cCsttt��|_dS(N(titerRR
R
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRes(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRcstTestXrangeCustomReversedcBseZd�ZRS(cCsttt��|_dS(N(RRR
R
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRjs(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR!hst	TestTuplecBseZd�ZRS(cCstttt���|_dS(N(R ttupleRR
R
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRos(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR"mst	TestDequecBseZd�ZRS(cCs1ttt��}t|�|_|j|_dS(N(RRR
R R
tpopR(Rtd((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyRvs(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR$tstTestDequeReversedcBseZd�ZRS(cCs1ttt��}t|�|_|j|_dS(N(RRR
RR
R%R(RR&((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR}s(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR'{stTestDictKeyscBseZd�ZRS(cCs4tjtt��}t|�|_|j|_dS(N(tdicttfromkeysRR
R R
tpopitemR(RR&((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�s(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR(�st
TestDictItemscBseZd�ZRS(cCs4tjtt��}|j�|_|j|_dS(N(R)R*RR
t	iteritemsR
R+R(RR&((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�s(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR,�stTestDictValuescBseZd�ZRS(cCs4tjtt��}|j�|_|j|_dS(N(R)R*RR
t
itervaluesR
R+R(RR&((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�s(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR.�stTestSetcBseZd�ZRS(cCs1ttt��}t|�|_|j|_dS(N(tsetRR
R R
R%R(RR&((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�s(RRR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR0�stTestListcBseZd�Zd�ZRS(cCsttt��|_dS(N(R trangeR
R
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�scCs�tt�}t|�}|j�|j�|jt|�td�|jt�|jt|�td�g|d)|jt|�d�|jt|�g�|jt	d��|jt|�d�dS(Niiii(
R3R
R RRRtappendtlisttextendR(RR&R
((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyt
test_mutation�s



(RRRR7(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR2�s	tTestListReversedcBseZd�Zd�ZRS(cCsttt��|_dS(N(RR3R
R
(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�scCs�tt�}t|�}|j�|j�|jt|�td�|jt�|jt|�td�g|d)|jt|�d�|jt|�g�|jt	d��|jt|�d�dS(Niiii(
R3R
RRRRR4R5R6R(RR&R
((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR7�s



(RRRR7(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR8�s	tBadLencBseZd�Zd�ZRS(cCsttd��S(Ni
(R R3(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyt__iter__�tcCstd��dS(Nthello(R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyt__len__�s(RRR:R=(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR9�s	t
BadLengthHintcBseZd�Zd�ZRS(cCsttd��S(Ni
(R R3(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR:�R;cCstd��dS(NR<(R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�s(RRR:R(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR>�s	tNoneLengthHintcBseZd�Zd�ZRS(cCsttd��S(Ni
(R R3(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR:�R;cCsdS(N(R(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR�s(RRR:R(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR?�s	tTestLengthHintExceptionscBseZd�Zd�ZRS(cCs6|jttt��|jttt��|jtgjt��|jtgjt��|jttt��|jttt��|jttdt��|jttdt��|jtt	t
t��|jtt	t
t��ttd��}|jt|jt��|jt|jt��dS(Ni
(
RRR5R9R>R6tziptfilterRtmaptchrt	bytearrayR3(Rtb((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyttest_issue1242657�scCs)|jtt��ttd���dS(Ni
(RR5R?R3(R((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyttest_invalid_hint�s(RRRGRH(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyR@�s	c
Cs>tttttttttt	t
ttg
}t
j|�dS(N(RRR!R"R$R'R(R,R.R0R2R8R@Rtrun_unittest(t	unittests((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyt	test_main�s	t__main__("t__doc__tunittestttestRt	itertoolsRtcollectionsRt__builtin__RRR
tTestCaseR	RRRR!R"R$R'R(R,R.R0R2R8tobjectR9R>R?R@RKR(((s8/usr/local/python-2.7/lib/python2.7/test/test_iterlen.pyt<module>*s8				
© 2025 GrazzMean