diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-11-13 16:18:32 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-11-13 16:18:32 (GMT) |
commit | bbc0d4409c4edc43d9f9b38bff089fd63f43734a (patch) | |
tree | e6a74fe2b0266d8fd9ab8fea8f34f1092aef374c /Lib/test | |
parent | fba73698240660d9154b6917b87dd333d6fb8284 (diff) | |
download | cpython-bbc0d4409c4edc43d9f9b38bff089fd63f43734a.zip cpython-bbc0d4409c4edc43d9f9b38bff089fd63f43734a.tar.gz cpython-bbc0d4409c4edc43d9f9b38bff089fd63f43734a.tar.bz2 |
SF bug 1065388: calendar day/month name lookup too slow
__getitem__() methods: compute only the new spellings needed to satisfy
the given indexing object. This is purely an optimization (it should
have no effect on visible semantics).
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_calendar.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py index 2dc486f..34d365b 100644 --- a/Lib/test/test_calendar.py +++ b/Lib/test/test_calendar.py @@ -37,10 +37,9 @@ class CalendarTestCase(unittest.TestCase): self.assertEqual(len(value), 7) self.assertEqual(len(value[:]), 7) # ensure they're all unique - d = {} - for v in value: - d[v] = 1 - self.assertEqual(len(d), 7) + self.assertEqual(len(set(value)), 7) + # verify it "acts like a sequence" in two forms of iteration + self.assertEqual(value[::-1], list(reversed(value))) def test_months(self): for attr in "month_name", "month_abbr": @@ -49,10 +48,9 @@ class CalendarTestCase(unittest.TestCase): self.assertEqual(len(value[:]), 13) self.assertEqual(value[0], "") # ensure they're all unique - d = {} - for v in value: - d[v] = 1 - self.assertEqual(len(d), 13) + self.assertEqual(len(set(value)), 13) + # verify it "acts like a sequence" in two forms of iteration + self.assertEqual(value[::-1], list(reversed(value))) class MonthCalendarTestCase(unittest.TestCase): |