Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
+ Coverage 97.43% 97.47% +0.04%
==========================================
Files 3 3
Lines 117 119 +2
==========================================
+ Hits 114 116 +2
Misses 3 3
🚀 New features to boost your workflow:
|
|
I'd strongly prefer keeping If users of the package prefer Looks good otherwise. |
|
I’m 100% convinced that accessing The 30ms flat delay (importing So since we’re not a CLI, and therefore don’t actually need to use DetailsIf I don’t completely misremember, I wrote that part of the official packaging guide, and intentionally chose the wording “many projects also choose” to clearly point out that that’s not a standard. I’ve read that discussion, and I’ve had long discussions with Isaac about this: he was focused on the niche use case “have multiple editable versions of packages in an environment and frequently switch between them via My firm opinion: anyone who wants runtime versions should engage with the standards process to get runtime metadata. The PyPA is very open to do this, but nobody ever cared enough to make a PEP. Footnotes
|
|
It's not just importing %timeit importlib.metadata.version("mudata")
232 μs ± 370 ns per loop (mean ± std. dev. of 7 runs, 1,000 loops each)
%timeit md.__version__
12.8 ns ± 0.00843 ns per loop (mean ± std. dev. of 7 runs, 100,000,000 loops each)EDIT: and may be even slower on network file systems, which are usually used in HPC environments. |
|
And as you can see that’s absolutely neglegible time-wise. It also won’t hit the disk every time as e.g. Linux caches files in memory. Nevertheless scanpy caches its result for some reason. I should probably get rid of that. If someone needs to have a check for scverse-misc’s version in a hot loop, they can cache it themselves after identifying it as a bottleneck in a benchmark. I’m very sure that won’t happen. Can we merge this? |
Also get rid of the
__version__attribute, I really want to discourage people from using that overimportlib.metadata.version. Versions are properties of distributions (PyPI packages), not import packages, and there is a canonical way in the stdlib to retrieve them using the distribution name. This is often the same, but doing things right makes things way less confusing when it isn’t the same.Also regarding
__version_tuple__: If people want a structured version, they can depend onpackagingand parse the version usingpackaging.version.Version. It’s extremely fast and all our packages importpackaginganyway at import time.