Tryag File Manager
Home
-
Turbo Force
Current Path :
/
proc
/
self
/
root
/
usr
/
lib
/
python2.4
/
test
/
Upload File :
New :
File
Dir
//proc/self/root/usr/lib/python2.4/test/test_iterlen.pyo
mò ‚=5Dc�����������@���s��d��Z��d�k�Z�d�k�l�Z�d�k�l�Z�l�Z�d�k�l�Z�d�k �l �Z �d�Z �d�e�i�f�d�„��ƒ��YZ�d �e�f�d �„��ƒ��YZ �d�e�f�d�„��ƒ��YZ�d �e�f�d�„��ƒ��YZ�d�e�f�d�„��ƒ��YZ�d�e�f�d�„��ƒ��YZ�d�e �f�d�„��ƒ��YZ�d�e �f�d�„��ƒ��YZ�d�e �f�d�„��ƒ��YZ�d�e �f�d�„��ƒ��YZ�d�e �f�d�„��ƒ��YZ�d�e �f�d�„��ƒ��YZ�d�e�f�d �„��ƒ��YZ�d!�e�f�d"�„��ƒ��YZ�d#�e�f�d$�„��ƒ��YZ�d%�e�f�d&�„��ƒ��YZ�e�d'�j�oA�e�e�e�e�e�e�e�e�e�e�e�e�e�e�g�Z�e�i�e�Œ��n�d�S((���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 permantently 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 dynanamically 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')). N(���s���test_support(���s���repeats���count(���s���deque(���s���UserListi ���t���TestInvariantWithoutMutationsc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s���|��i�}�xA�t�t�d�t�d�ƒ�ƒ�D]&�}�|��i�t�|�ƒ�|�ƒ�|�i�ƒ��q#�W|��i�t�|�ƒ�d�ƒ�|��i �t �|�i�ƒ�|��i�t�|�ƒ�d�ƒ�d��S(���Ni���i����(���t���selft���itt���reversedt���xranget���nt���it���assertEqualt���lent���nextt���assertRaisest ���StopIteration(���R���R���R���(����(����t'���/usr/lib/python2.4/test/test_iterlen.pyt���test_invariant6���s���� �(���t���__name__t ���__module__R ���(����(����(����R���R����4���s���t���TestTemporarilyImmutablec�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���sz���|��i�}�|��i�t�|�ƒ�t�ƒ�|�i�ƒ��|��i�t�|�ƒ�t�d�ƒ�|��i�ƒ��|��i�t�|�i�ƒ�|��i�t�|�ƒ�d�ƒ�d��S(���Ni���i����( ���R���R���R���R���R���R ���t���mutateR ���t���RuntimeError(���R���R���(����(����R���t���test_immutable_during_iterationA���s���� (���R���R���R���(����(����(����R���R���?���s���t ���TestRepeatc�����������B���s���t��Z�d�„��Z�d�„��Z�RS(���Nc���������C���s���t��d��t�ƒ�|��_�d��S(���N(���t���repeatt���NoneR���R���R���(���R���(����(����R���t���setUpQ���s����c���������C���s���|��i�t�t�t�d��ƒ�ƒ�d��S(���N(���R���R ���t ���TypeErrorR���R���R���(���R���(����(����R���t���test_no_len_for_infinite_repeatT���s����(���R���R���R���R���(����(����(����R���R���O���s��� t ���TestXrangec�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�ƒ�ƒ�|��_�d��S(���N(���t���iterR���R���R���R���(���R���(����(����R���R���Z���s����(���R���R���R���(����(����(����R���R���X���s���t���TestXrangeCustomReversedc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�ƒ�ƒ�|��_�d��S(���N(���R���R���R���R���R���(���R���(����(����R���R���_���s����(���R���R���R���(����(����(����R���R���]���s���t ���TestTuplec�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�t�ƒ�ƒ�ƒ�|��_�d��S(���N(���R���t���tupleR���R���R���R���(���R���(����(����R���R���d���s����(���R���R���R���(����(����(����R���R���b���s���t ���TestDequec�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s1���t��t�t�ƒ�ƒ�}�t�|�ƒ�|��_�|�i�|��_�d��S(���N( ���t���dequeR���R���t���dR���R���R���t���popR���(���R���R!���(����(����R���R���k���s����(���R���R���R���(����(����(����R���R���i���s���t���TestDequeReversedc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s1���t��t�t�ƒ�ƒ�}�t�|�ƒ�|��_�|�i�|��_�d��S(���N( ���R ���R���R���R!���R���R���R���R"���R���(���R���R!���(����(����R���R���r���s����(���R���R���R���(����(����(����R���R#���p���s���t���TestDictKeysc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s4���t��i�t�t�ƒ�ƒ�}�t�|�ƒ�|��_�|�i�|��_ �d��S(���N( ���t���dictt���fromkeysR���R���R!���R���R���R���t���popitemR���(���R���R!���(����(����R���R���y���s����(���R���R���R���(����(����(����R���R$���w���s���t ���TestDictItemsc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s4���t��i�t�t�ƒ�ƒ�}�|�i�ƒ��|��_�|�i�|��_ �d��S(���N( ���R%���R&���R���R���R!���t ���iteritemsR���R���R'���R���(���R���R!���(����(����R���R���€���s����(���R���R���R���(����(����(����R���R(���~���s���t���TestDictValuesc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s4���t��i�t�t�ƒ�ƒ�}�|�i�ƒ��|��_�|�i�|��_ �d��S(���N( ���R%���R&���R���R���R!���t ���itervaluesR���R���R'���R���(���R���R!���(����(����R���R���‡���s����(���R���R���R���(����(����(����R���R*���…���s���t���TestSetc�����������B���s���t��Z�d�„��Z�RS(���Nc���������C���s1���t��t�t�ƒ�ƒ�}�t�|�ƒ�|��_�|�i�|��_�d��S(���N( ���t���setR���R���R!���R���R���R���R"���R���(���R���R!���(����(����R���R���Ž���s����(���R���R���R���(����(����(����R���R,���Œ���s���t���TestListc�����������B���s���t��Z�d�„��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�ƒ�ƒ�|��_�d��S(���N(���R���t���rangeR���R���R���(���R���(����(����R���R���—���s����c���������C���sÐ���t��t�ƒ�}�t�|�ƒ�}�|�i�ƒ��|�i�ƒ��|��i�t�|�ƒ�t�d�ƒ�|�i �t�ƒ�|��i�t�|�ƒ�t�d�ƒ�g��|�d�)|��i�t�|�ƒ�d�ƒ�|��i�t �|�ƒ�g��ƒ�|�i�t�d�ƒ�ƒ�|��i�t�|�ƒ�d�ƒ�d��S(���Ni���i���i����i���( ���R/���R���R!���R���R���R ���R���R���R���t���appendt���listt���extendR���(���R���R!���R���(����(����R���t ���test_mutationš���s���� (���R���R���R���R3���(����(����(����R���R.���•���s��� t���TestListReversedc�����������B���s���t��Z�d�„��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�ƒ�ƒ�|��_�d��S(���N(���R���R/���R���R���R���(���R���(����(����R���R���ª���s����c���������C���sÐ���t��t�ƒ�}�t�|�ƒ�}�|�i�ƒ��|�i�ƒ��|��i�t�|�ƒ�t�d�ƒ�|�i �t�ƒ�|��i�t�|�ƒ�t�d�ƒ�g��|�d�)|��i�t�|�ƒ�d�ƒ�|��i�t �|�ƒ�g��ƒ�|�i�t�d�ƒ�ƒ�|��i�t�|�ƒ�d�ƒ�d��S(���Ni���i���i����i���( ���R/���R���R!���R���R���R ���R���R���R���R0���R1���R2���R���(���R���R!���R���(����(����R���R3������s���� (���R���R���R���R3���(����(����(����R���R4���¨���s��� t���TestSeqIterc�����������B���s���t��Z�d�„��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�t�ƒ�ƒ�ƒ�|��_�d��S(���N(���R���t���UserListR/���R���R���R���(���R���(����(����R���R���½���s����c���������C���sÖ���t��t�t�ƒ�ƒ�}�t�|�ƒ�}�|�i�ƒ��|�i�ƒ��|��i�t �|�ƒ�t�d�ƒ�|�i �t�ƒ�|��i�t �|�ƒ�t�d�ƒ�g��|�d�)|��i�t �|�ƒ�d�ƒ�|��i�t�|�ƒ�g��ƒ�|�i�t �d�ƒ�ƒ�|��i�t �|�ƒ�d�ƒ�d��S(���Ni���i���i����i���(���R6���R/���R���R!���R���R���R ���R���R���R���R0���R1���R2���R���(���R���R!���R���(����(����R���R3���À���s���� (���R���R���R���R3���(����(����(����R���R5���»���s��� t���TestSeqIterReversedc�����������B���s���t��Z�d�„��Z�d�„��Z�RS(���Nc���������C���s���t��t�t�t�ƒ�ƒ�ƒ�|��_�d��S(���N(���R���R6���R/���R���R���R���(���R���(����(����R���R���Ð���s����c���������C���sÖ���t��t�t�ƒ�ƒ�}�t�|�ƒ�}�|�i�ƒ��|�i�ƒ��|��i�t �|�ƒ�t�d�ƒ�|�i �t�ƒ�|��i�t �|�ƒ�t�d�ƒ�g��|�d�)|��i�t �|�ƒ�d�ƒ�|��i�t�|�ƒ�g��ƒ�|�i�t �d�ƒ�ƒ�|��i�t �|�ƒ�d�ƒ�d��S(���Ni���i���i����i���(���R6���R/���R���R!���R���R���R ���R���R���R���R0���R1���R2���R���(���R���R!���R���(����(����R���R3���Ó���s���� (���R���R���R���R3���(����(����(����R���R7���Î���s��� t���__main__(���t���__doc__t���unittestt���testt���test_supportt ���itertoolsR���t���countt���collectionsR ���R6���R���t���TestCaseR����R���R���R���R���R���R���R#���R$���R(���R*���R,���R.���R4���R5���R7���R���t ���unittestst���run_unittest(���R<���R ���R:���R.���R4���R���R����R6���R���R���R5���R#���R>���R,���RA���R���R*���R���R���R(���R7���R���R���R$���(����(����R���t���?*���s2��� 0