This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Simplify PyImport_ImportModuleLevelObject: avoid temporary tuple of str.partition/rpartition
Type: performance Stage:
Components: Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, eric.snow, ncoghlan, serhiy.storchaka, vstinner
Priority: normal Keywords: patch

Created on 2016-05-04 12:48 by vstinner, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
import.patch vstinner, 2016-05-04 12:48 review
Messages (4)
msg264809 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-05-04 12:48
Attached patch simplifies PyImport_ImportModuleLevelObject to avoid the temporary tuple created by str.partition/rpartition(). I don't expect any difference on the performance, it's more to cleanup the code.
msg264814 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-04 13:23
LGTM, but I left a couple of minor suggestions on Rietveld. I hope they can make the code yet cleaner.
msg264871 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2016-05-05 01:54
No objections from me (and I don't have anything to add to Serhiy's comments on the code review)
msg265923 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-05-20 09:38
I modified my patch to address Serhiy's comments. Thanks for the your review Serhiy.

changeset:   101442:779563dd701c
tag:         tip
user:        Victor Stinner <victor.stinner@gmail.com>
date:        Fri May 20 11:36:13 2016 +0200
files:       Python/import.c
description:
Cleanup import.c

* Replace PyUnicode_RPartition() with PyUnicode_FindChar() and
  PyUnicode_Substring() to avoid the creation of a temporary tuple.
* Use PyUnicode_FromFormat() to build a string and avoid the single_dot ('.')
  singleton

Thanks Serhiy Storchaka for your review.
History
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71135
2016-05-20 09:38:13vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg265923
2016-05-05 01:54:07ncoghlansetmessages: + msg264871
2016-05-04 13:23:53serhiy.storchakasetnosy: + brett.cannon, ncoghlan, eric.snow
messages: + msg264814
2016-05-04 12:48:16vstinnercreate