kopia lustrzana https://github.com/micropython/micropython-lib
heapq: Import itertools only for functions which really require it.
rodzic
3de140698c
commit
bf811614cf
|
@ -127,7 +127,7 @@ From all times, sorting has always been a Great Art! :-)
|
|||
__all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',
|
||||
'nlargest', 'nsmallest', 'heappushpop']
|
||||
|
||||
from itertools import islice, count, tee, chain
|
||||
#from itertools import count, tee, chain
|
||||
|
||||
def heappush(heap, item):
|
||||
"""Push item onto heap, maintaining the heap invariant."""
|
||||
|
@ -197,6 +197,7 @@ def nlargest(n, iterable):
|
|||
|
||||
Equivalent to: sorted(iterable, reverse=True)[:n]
|
||||
"""
|
||||
from itertools import islice, count, tee, chain
|
||||
if n < 0:
|
||||
return []
|
||||
it = iter(iterable)
|
||||
|
@ -215,6 +216,7 @@ def nsmallest(n, iterable):
|
|||
|
||||
Equivalent to: sorted(iterable)[:n]
|
||||
"""
|
||||
from itertools import islice, count, tee, chain
|
||||
if n < 0:
|
||||
return []
|
||||
it = iter(iterable)
|
||||
|
@ -392,6 +394,7 @@ def nsmallest(n, iterable, key=None):
|
|||
|
||||
Equivalent to: sorted(iterable, key=key)[:n]
|
||||
"""
|
||||
from itertools import islice, count, tee, chain
|
||||
# Short-cut for n==1 is to use min() when len(iterable)>0
|
||||
if n == 1:
|
||||
it = iter(iterable)
|
||||
|
@ -430,6 +433,7 @@ def nlargest(n, iterable, key=None):
|
|||
Equivalent to: sorted(iterable, key=key, reverse=True)[:n]
|
||||
"""
|
||||
|
||||
from itertools import islice, count, tee, chain
|
||||
# Short-cut for n==1 is to use max() when len(iterable)>0
|
||||
if n == 1:
|
||||
it = iter(iterable)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
srctype = cpython
|
||||
type = module
|
||||
version = 0.9.1
|
||||
version = 0.9.2
|
||||
# Module uses in *some* functions, but we don't want to depend on it
|
||||
#depends = itertools
|
||||
|
|
|
@ -6,7 +6,7 @@ from setuptools import setup
|
|||
|
||||
|
||||
setup(name='micropython-heapq',
|
||||
version='0.9.1',
|
||||
version='0.9.2',
|
||||
description='CPython heapq module ported to MicroPython',
|
||||
long_description='This is a module ported from CPython standard library to be compatible with\nMicroPython interpreter. Usually, this means applying small patches for\nfeatures not supported (yet, or at all) in MicroPython. Sometimes, heavier\nchanges are required. Note that CPython modules are written with availability\nof vast resources in mind, and may not work for MicroPython ports with\nlimited heap. If you are affected by such a case, please help reimplement\nthe module from scratch.',
|
||||
url='https://github.com/micropython/micropython/issues/405',
|
||||
|
|
Ładowanie…
Reference in New Issue