Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an implementation of importlib.abc.InspectLoader.get_code #62272

Closed
brettcannon opened this issue May 27, 2013 · 3 comments
Closed

Add an implementation of importlib.abc.InspectLoader.get_code #62272

brettcannon opened this issue May 27, 2013 · 3 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@brettcannon
Copy link
Member

BPO 18072
Nosy @brettcannon, @ncoghlan, @ericvsmith, @ericsnowcurrently

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/brettcannon'
closed_at = <Date 2013-05-28.01:15:26.399>
created_at = <Date 2013-05-27.15:03:42.943>
labels = ['library']
title = 'Add an implementation of importlib.abc.InspectLoader.get_code'
updated_at = <Date 2013-05-28.01:15:26.398>
user = 'https://github.com/brettcannon'

bugs.python.org fields:

activity = <Date 2013-05-28.01:15:26.398>
actor = 'brett.cannon'
assignee = 'brett.cannon'
closed = True
closed_date = <Date 2013-05-28.01:15:26.399>
closer = 'brett.cannon'
components = ['Library (Lib)']
creation = <Date 2013-05-27.15:03:42.943>
creator = 'brett.cannon'
dependencies = []
files = []
hgrepos = []
issue_num = 18072
keywords = []
message_count = 3.0
messages = ['190143', '190161', '190163']
nosy_count = 5.0
nosy_names = ['brett.cannon', 'ncoghlan', 'eric.smith', 'python-dev', 'eric.snow']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue18072'
versions = ['Python 3.4']

@brettcannon
Copy link
Member Author

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.

@brettcannon brettcannon added the stdlib Python modules in the Lib dir label May 27, 2013
@brettcannon brettcannon self-assigned this May 27, 2013
@brettcannon
Copy link
Member Author

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.

@python-dev
Copy link
Mannequin

python-dev mannequin commented May 28, 2013

New changeset 11510db74223 by Brett Cannon in branch 'default':
Issue bpo-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 bpo-18072
http://hg.python.org/cpython/rev/2ea849fde22b

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant