[issue41340] Not very good strcpy implementation in cpython/Python/strdup.c

fj92f3jj923f923 report at bugs.python.org
Sun Jul 19 06:36:04 EDT 2020


New submission from fj92f3jj923f923 <watashiwaher at gmail.com>:

Hi, all!

strdup implementation inside cpython/Python/strdup.c is not the best one.
It calls strlen + strcpy, which is the same as calling strlen twice + memcpy.
So I replaced it by the call of strlen + memcpy.

It is easy to look any implementation in any library.
Here for example:
https://code.woboq.org/userspace/glibc/string/strdup.c.html

So I fixed it here:
https://github.com/python/cpython/pull/21544

----------
components: C API
messages: 373955
nosy: fj92f3jj923f923
priority: normal
severity: normal
status: open
title: Not very good strcpy implementation in cpython/Python/strdup.c
type: performance
versions: Python 3.10

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41340>
_______________________________________


More information about the Python-bugs-list mailing list