Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/future/builtins/iterators.py: 69%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

16 statements  

1""" 

2This module is designed to be used as follows:: 

3 

4 from future.builtins.iterators import * 

5 

6And then, for example:: 

7 

8 for i in range(10**15): 

9 pass 

10 

11 for (a, b) in zip(range(10**15), range(-10**15, 0)): 

12 pass 

13 

14Note that this is standard Python 3 code, plus some imports that do 

15nothing on Python 3. 

16 

17The iterators this brings in are:: 

18 

19- ``range`` 

20- ``filter`` 

21- ``map`` 

22- ``zip`` 

23 

24On Python 2, ``range`` is a pure-Python backport of Python 3's ``range`` 

25iterator with slicing support. The other iterators (``filter``, ``map``, 

26``zip``) are from the ``itertools`` module on Python 2. On Python 3 these 

27are available in the module namespace but not exported for * imports via 

28__all__ (zero no namespace pollution). 

29 

30Note that these are also available in the standard library 

31``future_builtins`` module on Python 2 -- but not Python 3, so using 

32the standard library version is not portable, nor anywhere near complete. 

33""" 

34 

35from __future__ import division, absolute_import, print_function 

36 

37import itertools 

38from future import utils 

39 

40if not utils.PY3: 

41 filter = itertools.ifilter 

42 map = itertools.imap 

43 from future.types import newrange as range 

44 zip = itertools.izip 

45 __all__ = ['filter', 'map', 'range', 'zip'] 

46else: 

47 import builtins 

48 filter = builtins.filter 

49 map = builtins.map 

50 range = builtins.range 

51 zip = builtins.zip 

52 __all__ = []