[issue47070] Improve performance of array_inplace_repeat

2022-03-28 Thread Dennis Sweeney


Dennis Sweeney  added the comment:


New changeset 850687df47b03e98c1433e6e70e71a8921eb4454 by Pieter Eendebak in 
branch 'main':
bpo-47070: Add _PyBytes_Repeat() (GH-31999)
https://github.com/python/cpython/commit/850687df47b03e98c1433e6e70e71a8921eb4454


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47070] Improve performance of array_inplace_repeat

2022-03-19 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

I'd bet we could add a couple of utility functions that could be used in 
multiple places, to keep the "trick" all in one place. Something like

void
_PyBytes_RepeatInPlace(char **buffer, size_t start_len, size_t end_len)
{
// Repeatedly double.
size_t copied = start_len;
while (copied < end_len) {
size_t to_copy = Py_MIN(copied, end_len - copied);
memcpy(buffer + copied, buffer, to_copy);
copied += to_copy;
}
}

void
_PyBytes_Repeat(char *dest, size_t len_dest,
const char *src, size_t len_src)
{
// XXX maybe handle zero lengths
// XXX maybe use memset for len_src == 1
memcpy(dest, src, len_src);
_PyBytes_RepeatInPlace(dest, len_src, len_dest);
}

--
nosy: +Dennis Sweeney

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47070] Improve performance of array_inplace_repeat

2022-03-19 Thread Pieter Eendebak


Change by Pieter Eendebak :


--
keywords: +patch
pull_requests: +30088
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/31999

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue47070] Improve performance of array_inplace_repeat

2022-03-19 Thread Pieter Eendebak


New submission from Pieter Eendebak :

The array_inplace_repeat is inefficient for small arrays and a high number of 
repeats. This can be improved by using the same approach as in 
https://bugs.python.org/issue47005

--
components: Interpreter Core
messages: 415572
nosy: pieter.eendebak
priority: normal
severity: normal
status: open
title: Improve performance of array_inplace_repeat
type: performance
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com