Re: PEP 451: Big update.
Nick Coghlan <[email protected]> Fri, 20 Sep 2013 00:30:29 +1000
| Newsgroups | gmane.comp.python.import |
|---|---|
| Message-ID | <CADiSq7e+zVkvNhxUStFM7ZBdzPCzgZyKrDaThWpcSjfpsK+xmw@mail.gmail.com> |
On 20 Sep 2013 00:12, "Brett Cannon" <[email protected]> wrote: > > > > > On Thu, Sep 19, 2013 at 6:22 AM, Antoine Pitrou <[email protected]> wrote: >> >> >> Hi, >> >> I have some questions and comments: >> >> > origin - a string for the location from which the module is loaded, >> > e.g. "builtin" for built-in modules and the filename for modules >> > loaded from source. >> >> Filename or filepath? What if the module is stored in e.g. a ZIP file? > > > I think this would be what __file__ would be set to for zipfiles, so for zip files it would be e.g. /some/file.zip/path/to/module.py > >> >> >> > submodule_search_locations - list of strings for where to find >> > submodules, if a package (None otherwise). >> >> Why isn't is_package exposed as an attribute too? > > > It's redundant. The test for whether something is a package is literally ``submodule_search_locations is not None``. It just doesn't isn't complicated enough to warrant another attribute. Plus being a package isn't as important per-se as a concept as much as having a search path. > >> >> >> > cached (property) - a string for where the compiled module will be >> > stored >> >> "where" is a filesystem location? >> (absolute? relative to the origin?) > > > It's what http://docs.python.org/3/library/imp.html#imp.cache_from_source would return. > >> >> >> > has_location (RO-property) - the module's origin refers to a location. >> >> filesystem location? What about ZIP files? > > > It's a flag to basically say that origin contains what __file__ should be. Thus indicating that get_data() on the loader can be used sensibly. Perhaps we could just make setting __file__ conditional on the loader defining get_data, rather than having it be a spec attribute? I also suggest that we adopt the convention of using angle brackets in non-location origins. So names like "<builtin>" and "<frozen>". To respond to something Paul said, our completely opaque token is "loader_state", origin is still intended to be a human readable string. Cheers, Nick. > > -Brett > >> >> >> > spec_from_file_location(name, location, *, loader=None, >> > submodule_search_locations=None) - factory for file-based module specs >> >> What does it mean? Is it able to make "intelligent" decisions depending >> on e.g. whether the module is an extension module or a pure Python >> module? >> >> > from_loader(name, loader, *, origin=None, is_package=None) - factory >> > based on information provided by loaders. >> >> That description is rather unhelpful. >> >> > importlib.find_spec(name, path=None) will return the spec for a module. >> >> Is the module supposed to be already loaded or not? How is the spec >> "found"? >> >> Regards >> >> Antoine. >> >> >> _______________________________________________ >> Import-SIG mailing list >> [email protected] >> https://mail.python.org/mailman/listinfo/import-sig > > > > _______________________________________________ > Import-SIG mailing list > [email protected] > https://mail.python.org/mailman/listinfo/import-sig > _______________________________________________ Import-SIG mailing list [email protected] https://mail.python.org/mailman/listinfo/import-sig