comparison mercurial/revset.py @ 28717:c5f212c8ad78

pypy: fix doctests for pypy optimizations PyPy would sometime call __len__ at points where it things preallocating the container makes sense. Change the doctests so they're using generator expressions and not list comprehensions
author Maciej Fijalkowski <fijall@gmail.com>
date Thu, 31 Mar 2016 18:38:08 +0200
parents ab06b5ef93f7
children f103f985ac00
comparison
equal deleted inserted replaced
28716:5c14af475f61 28717:c5f212c8ad78
3058 >>> bool(rs), 0 in rs, rs.first(), rs.last() 3058 >>> bool(rs), 0 in rs, rs.first(), rs.last()
3059 (False, False, None, None) 3059 (False, False, None, None)
3060 3060
3061 iterate unsorted: 3061 iterate unsorted:
3062 >>> rs = addset(xs, ys) 3062 >>> rs = addset(xs, ys)
3063 >>> [x for x in rs] # without _genlist 3063 >>> # (use generator because pypy could call len())
3064 >>> list(x for x in rs) # without _genlist
3064 [0, 3, 2, 5, 4] 3065 [0, 3, 2, 5, 4]
3065 >>> assert not rs._genlist 3066 >>> assert not rs._genlist
3066 >>> len(rs) 3067 >>> len(rs)
3067 5 3068 5
3068 >>> [x for x in rs] # with _genlist 3069 >>> [x for x in rs] # with _genlist
3069 [0, 3, 2, 5, 4] 3070 [0, 3, 2, 5, 4]
3070 >>> assert rs._genlist 3071 >>> assert rs._genlist
3071 3072
3072 iterate ascending: 3073 iterate ascending:
3073 >>> rs = addset(xs, ys, ascending=True) 3074 >>> rs = addset(xs, ys, ascending=True)
3074 >>> [x for x in rs], [x for x in rs.fastasc()] # without _asclist 3075 >>> # (use generator because pypy could call len())
3076 >>> list(x for x in rs), list(x for x in rs.fastasc()) # without _asclist
3075 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5]) 3077 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
3076 >>> assert not rs._asclist 3078 >>> assert not rs._asclist
3077 >>> len(rs) 3079 >>> len(rs)
3078 5 3080 5
3079 >>> [x for x in rs], [x for x in rs.fastasc()] 3081 >>> [x for x in rs], [x for x in rs.fastasc()]
3080 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5]) 3082 ([0, 2, 3, 4, 5], [0, 2, 3, 4, 5])
3081 >>> assert rs._asclist 3083 >>> assert rs._asclist
3082 3084
3083 iterate descending: 3085 iterate descending:
3084 >>> rs = addset(xs, ys, ascending=False) 3086 >>> rs = addset(xs, ys, ascending=False)
3085 >>> [x for x in rs], [x for x in rs.fastdesc()] # without _asclist 3087 >>> # (use generator because pypy could call len())
3088 >>> list(x for x in rs), list(x for x in rs.fastdesc()) # without _asclist
3086 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0]) 3089 ([5, 4, 3, 2, 0], [5, 4, 3, 2, 0])
3087 >>> assert not rs._asclist 3090 >>> assert not rs._asclist
3088 >>> len(rs) 3091 >>> len(rs)
3089 5 3092 5
3090 >>> [x for x in rs], [x for x in rs.fastdesc()] 3093 >>> [x for x in rs], [x for x in rs.fastdesc()]