Skip to content

Commit f29ca0b

Browse files
authored
Merge branch 'main' into fetch-restore
2 parents df86e20 + d71edbd commit f29ca0b

File tree

15 files changed

+109
-56
lines changed

15 files changed

+109
-56
lines changed

Doc/library/asyncio-eventloop.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ Opening network connections
524524
When a server's IPv4 path and protocol are working, but the server's
525525
IPv6 path and protocol are not working, a dual-stack client
526526
application experiences significant connection delay compared to an
527-
IPv4-only client. This is undesirable because it causes the dual-
528-
stack client to have a worse user experience. This document
527+
IPv4-only client. This is undesirable because it causes the
528+
dual-stack client to have a worse user experience. This document
529529
specifies requirements for algorithms that reduce this user-visible
530530
delay and provides an algorithm.
531531

Doc/library/typing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ These are not used in annotations. They are building blocks for creating generic
15881588
methods, not their type signatures. For example, :class:`ssl.SSLObject`
15891589
is a class, therefore it passes an :func:`issubclass`
15901590
check against :data:`Callable`. However, the
1591-
:meth:`ssl.SSLObject.__init__` method exists only to raise a
1591+
``ssl.SSLObject.__init__`` method exists only to raise a
15921592
:exc:`TypeError` with a more informative message, therefore making
15931593
it impossible to call (instantiate) :class:`ssl.SSLObject`.
15941594

Lib/ensurepip/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__all__ = ["version", "bootstrap"]
1212
_PACKAGE_NAMES = ('setuptools', 'pip')
1313
_SETUPTOOLS_VERSION = "65.5.0"
14-
_PIP_VERSION = "23.0"
14+
_PIP_VERSION = "23.0.1"
1515
_PROJECTS = [
1616
("setuptools", _SETUPTOOLS_VERSION, "py3"),
1717
("pip", _PIP_VERSION, "py3"),

Lib/test/test_bool.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def test_float(self):
4040
self.assertEqual(float(True), 1.0)
4141
self.assertIsNot(float(True), True)
4242

43+
def test_complex(self):
44+
self.assertEqual(complex(False), 0j)
45+
self.assertEqual(complex(False), False)
46+
self.assertEqual(complex(True), 1+0j)
47+
self.assertEqual(complex(True), True)
48+
4349
def test_math(self):
4450
self.assertEqual(+False, 0)
4551
self.assertIsNot(+False, False)

Lib/test/test_zipfile/_context.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

Lib/test/test_zipfile/_func_timeout_compat.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

Lib/test/test_zipfile/_itertools.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import itertools
2+
from collections import deque
3+
from itertools import islice
24

35

46
# from jaraco.itertools 6.3.0
@@ -39,3 +41,39 @@ def always_iterable(obj, base_type=(str, bytes)):
3941
return iter(obj)
4042
except TypeError:
4143
return iter((obj,))
44+
45+
46+
# from more_itertools v9.0.0
47+
def consume(iterator, n=None):
48+
"""Advance *iterable* by *n* steps. If *n* is ``None``, consume it
49+
entirely.
50+
Efficiently exhausts an iterator without returning values. Defaults to
51+
consuming the whole iterator, but an optional second argument may be
52+
provided to limit consumption.
53+
>>> i = (x for x in range(10))
54+
>>> next(i)
55+
0
56+
>>> consume(i, 3)
57+
>>> next(i)
58+
4
59+
>>> consume(i)
60+
>>> next(i)
61+
Traceback (most recent call last):
62+
File "<stdin>", line 1, in <module>
63+
StopIteration
64+
If the iterator has fewer items remaining than the provided limit, the
65+
whole iterator will be consumed.
66+
>>> i = (x for x in range(3))
67+
>>> consume(i, 5)
68+
>>> next(i)
69+
Traceback (most recent call last):
70+
File "<stdin>", line 1, in <module>
71+
StopIteration
72+
"""
73+
# Use functions that consume iterators at C speed.
74+
if n is None:
75+
# feed the entire iterator into a zero-length deque
76+
deque(iterator, maxlen=0)
77+
else:
78+
# advance to the empty slice starting at position n
79+
next(islice(iterator, n, n), None)

Lib/test/test_zipfile/_support.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import importlib
2+
import unittest
3+
4+
5+
def import_or_skip(name):
6+
try:
7+
return importlib.import_module(name)
8+
except ImportError: # pragma: no cover
9+
raise unittest.SkipTest(f'Unable to import {name}')
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import unittest
2+
import string
3+
import zipfile
4+
5+
from ._functools import compose
6+
from ._itertools import consume
7+
8+
from ._support import import_or_skip
9+
10+
11+
big_o = import_or_skip('big_o')
12+
13+
14+
class TestComplexity(unittest.TestCase):
15+
def test_implied_dirs_performance(self):
16+
best, others = big_o.big_o(
17+
compose(consume, zipfile.CompleteDirs._implied_dirs),
18+
lambda size: [
19+
'/'.join(string.ascii_lowercase + str(n)) for n in range(size)
20+
],
21+
max_n=1000,
22+
min_n=1,
23+
)
24+
assert best <= big_o.complexities.Linear

0 commit comments

Comments
 (0)