Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,7 @@ objects.

See the :ref:`What's New <whatsnew315-bytearray-take-bytes>` entry for
common code patterns which can be optimized with
:func:`bytearray.take_bytes`.
:meth:`bytearray.take_bytes`.

Since bytearray objects are sequences of integers (akin to a list), for a
bytearray object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be
Expand Down
6 changes: 3 additions & 3 deletions Lib/encodings/punycode.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def segregate(str):
else:
extended.add(c)
extended = sorted(extended)
return bytes(base), extended
return base.take_bytes(), extended

def selective_len(str, max):
"""Return the length of str, considering only characters below max."""
Expand Down Expand Up @@ -83,7 +83,7 @@ def generate_generalized_integer(N, bias):
t = T(j, bias)
if N < t:
result.append(digits[N])
return bytes(result)
return result.take_bytes()
result.append(digits[t + ((N - t) % (36 - t))])
N = (N - t) // (36 - t)
j += 1
Expand Down Expand Up @@ -112,7 +112,7 @@ def generate_integers(baselen, deltas):
s = generate_generalized_integer(delta, bias)
result.extend(s)
bias = adapt(delta, points==0, baselen+points+1)
return bytes(result)
return result.take_bytes()

def punycode_encode(text):
base, extended = segregate(text)
Expand Down
2 changes: 1 addition & 1 deletion Lib/re/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
# less significant byte is a bit index in the chunk (just like the
# CHARSET matching).

charmap = bytes(charmap) # should be hashable
charmap = charmap.take_bytes() # should be hashable
comps = {}
mapping = bytearray(256)
block = 0
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.15.0a2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,7 @@ under no memory.
.. section: Core and Builtins

Update :class:`bytearray` to use a :class:`bytes` under the hood as its
buffer and add :func:`bytearray.take_bytes` to take it out.
buffer and add :meth:`bytearray.take_bytes` to take it out.

..

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Update :ref:`asyncio-streams` to use :func:`bytearray.take_bytes` for a over
Update :ref:`asyncio-streams` to use :meth:`bytearray.take_bytes` for a over
10% performance improvement on pyperformance asyncio_tcp benchmark.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Remove a data copy from :func:`base64.b32decode` and
:func:`base64.b32encode` by using :func:`bytearray.take_bytes`.
:func:`base64.b32encode` by using :meth:`bytearray.take_bytes`.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Remove data copy from :func:`wave.Wave_read.readframes` and
:func:`wave.Wave_write.writeframes` by using :func:`bytearray.take_bytes`.
:func:`wave.Wave_write.writeframes` by using :meth:`bytearray.take_bytes`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove data copy from :mod:`codecs` ``punycode`` encoding by using
:meth:`bytearray.take_bytes`.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Remove data copy from :mod:`encodings.idna` :meth:`~codecs.Codec.encode` and
:meth:`~codecs.IncrementalEncoder.encode` by using :func:`bytearray.take_bytes`.
:meth:`~codecs.IncrementalEncoder.encode` by using :meth:`bytearray.take_bytes`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove data copy from :mod:`re` compilation of regexes with large charsets
by using :meth:`bytearray.take_bytes`.
4 changes: 4 additions & 0 deletions Tools/c-analyzer/cpython/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def format_tsv_lines(lines):
('*', './Include/internal/mimalloc'),

('Modules/_decimal/**/*.c', 'Modules/_decimal/libmpdec'),

('Modules/_elementtree.c', 'Modules/expat'),
('Modules/pyexpat.c', 'Modules/expat'),

('Modules/_hacl/*.c', 'Modules/_hacl/include'),
('Modules/_hacl/*.c', 'Modules/_hacl/'),
('Modules/_hacl/*.h', 'Modules/_hacl/include'),
Expand All @@ -125,6 +128,7 @@ def format_tsv_lines(lines):
('Modules/sha3module.c', 'Modules/_hacl/include'),
('Modules/blake2module.c', 'Modules/_hacl/include'),
('Modules/hmacmodule.c', 'Modules/_hacl/include'),

('Objects/stringlib/*.h', 'Objects'),

# possible system-installed headers, just in case
Expand Down
Loading