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: Add an implementation of importlib.abc.InspectLoader.get_code
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, eric.smith, eric.snow, ncoghlan, python-dev
Priority: normal Keywords:

Created on 2013-05-27 15:03 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg190143 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-05-27 15:03
I'm contemplating adding an implementation of importlib.abc.InspectLoader.get_code() which relies on get_source() (and then another version in ExecutionLoader which uses get_filename()). The reason I'm hesitant is get_source() is often an expensive operation thanks to having to decode the source code and do a universal newline conversion.

Now I could add the implementation but leave the method abstract, forcing users to make the decision to call super().get_code(), although that's still easy enough that I'm afraid people still won't take into consideration the performance implications.

But maybe I'm worrying too much? We're consenting adults, right? So for that reason I'm leaning towards implementing but leaving abstract with a note in the docs that performance should be considered before just blindly calling the abstract method.
msg190161 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-05-27 23:36
So it turns out I will simply have to make the methods not abstract anymore. Thanks to multiple inheritance I can't implement the method in ExecutionLoader and keep it abstract in case someone subclasses InspectLoader and then creates another subclass of ExecutionLoader and the InspectLoader subclass w/o making ExecutionLoader.get_code not abstract. But if I can't do it there then it seems silly to leave only InspectLoader.get_code abstract.

IOW get_code will not longer be abstract and I will leave a note in the docs to mention you probably want to consider overriding the method for performance.
msg190163 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-28 01:12
New changeset 11510db74223 by Brett Cannon in branch 'default':
Issue #18072: Implement get_code() for importlib.abc.InspectLoader and
http://hg.python.org/cpython/rev/11510db74223

New changeset 2ea849fde22b by Brett Cannon in branch 'default':
NEWS entry for issue #18072
http://hg.python.org/cpython/rev/2ea849fde22b
History
Date User Action Args
2022-04-11 14:57:46adminsetgithub: 62272
2013-05-28 01:15:26brett.cannonsetstatus: open -> closed
resolution: fixed
stage: resolved
2013-05-28 01:12:50python-devsetnosy: + python-dev
messages: + msg190163
2013-05-27 23:36:53brett.cannonsetmessages: + msg190161
2013-05-27 15:08:10brett.cannonsetassignee: brett.cannon
2013-05-27 15:08:05brett.cannonsetnosy: + eric.smith
2013-05-27 15:03:42brett.cannoncreate