From b9a898d7963abf68d04c3314009f96c37f7876e3 Mon Sep 17 00:00:00 2001 From: Piotr Maslanka <piotr.maslanka@henrietta.com.pl> Date: Sat, 7 Oct 2017 12:39:24 +0200 Subject: [PATCH] minor TimerHeap fixes --- CHANGELOG.md | 3 +++ satella/coding/structures.py | 5 +++++ setup.py | 2 +- tests/test_coding/test_structures.py | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e67db78..0c221fca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v2.0.12 + +* Pomniejsze usprawnienia do TimerHeap ## v2.0.11 diff --git a/satella/coding/structures.py b/satella/coding/structures.py index 4a55e7c9..be65187b 100644 --- a/satella/coding/structures.py +++ b/satella/coding/structures.py @@ -227,6 +227,11 @@ class TimeBasedHeap(Heap): def __repr__(self): return u'<satella.coding.TimeBasedHeap>' + @returns_iterable + def items(self): + """Return an iterator, but WITHOUT timestamps (only items), in unspecified order""" + return (ts, ob for ts, ob in self.heap) + def __init__(self): """ Initialize an empty heap diff --git a/setup.py b/setup.py index 95ce08f2..846f98fe 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup(name='satella', - version='2.0.11', + version='2.0.12dev1', description=u'Utilities for writing servers in Python', author=u'Piotr MaĹlanka', author_email='piotrm@smok.co', diff --git a/tests/test_coding/test_structures.py b/tests/test_coding/test_structures.py index 6bc4eb13..ab2b9b64 100644 --- a/tests/test_coding/test_structures.py +++ b/tests/test_coding/test_structures.py @@ -21,6 +21,12 @@ class TestTimeBasedHeap(unittest.TestCase): self.assertNotIn((30, 'kota'), q) + def test_imprv(self): + tbh = TimeBasedHeap() + tbh.put(10, 'ala') + + self.assertIn('ala', list(tbh.items())) + class TestHeap(unittest.TestCase): def test_push(self): -- GitLab