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

New is_pickled_module() function #556

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

leogama
Copy link
Contributor

@leogama leogama commented Oct 4, 2022

From #475 / #527
Also fixes _identify_module() -> raises exception for modules saved with dump()

@leogama leogama changed the title New is_pickled_module() function New is_pickled_module() function Oct 4, 2022
@mmckerns mmckerns self-requested a review October 4, 2022 15:41
@mmckerns mmckerns added this to the dill-0.3.7 milestone Oct 23, 2022
Copy link
Member

@mmckerns mmckerns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really nice. Sorry about the delay. Let's have a small think about naming of the function, what it returns, and the naming of importable kwarg (and it's docs). Otherwise LGTM.

return False
is_runtime_mod = pickle_main.startswith('__runtime__.')
res = importable ^ is_runtime_mod
if res and identify:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function could be named pickled_module or identify_module, and the identify kwarg set to always be true and then removed.


Parameters:
filename: a path-like object or a readable stream.
importable: expected kind of the file's saved module. Use `True` for
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc is slightly confusing, especially if people might think that the file itself is importable (without first unpickling). Fundamentally, it's either a file-like module object or a module class instance... so is something in that vein a better name? It's a bit of an unusual thing for people to think about, so lets give the name some extra thought.

@mmckerns mmckerns modified the milestones: dill-0.3.7, dill-0.3.8 Mar 21, 2023
@mmckerns mmckerns modified the milestones: dill-0.3.8, dill-0.3.9 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants