Coverage for pygeodesy/lazily.py: 96%
213 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-29 12:40 -0400
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-29 12:40 -0400
2# -*- coding: utf-8 -*-
4u'''Lazily import C{pygeodesy} modules and attributes, based on
5U{lazy_import<https://modutil.ReadTheDocs.io/en/latest/#lazy_import>}
6from I{Brett Cannon}'s U{modutil<https://PyPI.org/project/modutil>}.
8C{Lazy import} is I{supported only for }U{Python 3.7+
9<https://Snarky.Ca/lazy-importing-in-python-3-7>} and is I{enabled by
10default} in U{PyGeodesy 18.11.10<https://PyPI.org/project/PyGeodesy>}
11I{and newer}.
13To I{enable} C{lazy import}, set C{env} variable C{PYGEODESY_LAZY_IMPORT}
14to C{1}, C{2}, C{3} or higher prior to C{import pygeodesy}. To I{disable}
15C{lazy import}, set C{env} variable C{PYGEODESY_LAZY_IMPORT} to C{0} or
16an empty string. Use C{2} or higher to print a message for each lazily
17imported module and attribute, similar to C{env} variable C{PYTHONVERBOSE}
18showing imports. Using C{3} or higher also shows the importing file name
19and line number.
21@note: C{Lazy import} applies only to top-level modules of C{pygeodesy}.
22 The C{lazy import} of a top-level module invariably loads all
23 sub-modules imported by that top-level module.
25@note: C{Lazy import} raises a L{LazyAttributeError} or L{LazyImportError}
26 depending on the cause of the error and such errors can occur late,
27 after all initial imports.
28'''
30from pygeodesy import internals as _internals, interns as _interns, \
31 _isfrozen # DON'T _lazy_import2
32# from pygeodesy.errors import _error_init, _xkwds_item2 # _ALL_MODS
33from pygeodesy.internals import _caller3, _envPYGEODESY, _headof, printf, _tailof, \
34 typename, _versions # _getenv, _PYGEODESY_ENV, \
35# _MODS_Base, _MODS.sys_version_info2
36from pygeodesy.interns import _attribute_, _by_, _COLONSPACE_, _COMMASPACE_, _DALL_, \
37 _DMAIN_, _doesn_t_exist_, _DOT_, _EQUALSPACED_, _from_, \
38 _HASH_, _immutable_, _line_, _module_, NN, _no_, _not_, \
39 _pygeodesy_, _pygeodesy_abspath_, _SPACE_, _SUB_PACKAGES, \
40 _or_, _UNDER_, _version_, _sys, _intern # function, _1_
41try:
42 from importlib import import_module
43except ImportError as x: # Python 2.6-
44 raise ImportError(_COLONSPACE_(x, _versions()))
45# import sys as _sys # from .interns
47_a0 = () # PYCHOK empty tuple
48_asSPACED_ = ' as '
49_FOR_DOCS = _envPYGEODESY('FOR_DOCS') # for epydoc ...
50_imported_ = 'imported'
51_init__all__ = _FOR_DOCS or _envPYGEODESY('_init__all__', _DALL_) == _DALL_ # PYCHOK exported
52_lazily_ = 'lazily'
53_PYTHON_X_DEV = getattr(_sys.flags, 'dev_mode', False) # PYCHOK Python 3.2+
54_unlazy = _unLazy0 = _isfrozen or _internals._MODS.sys_version_info2 < (3, 7) # PYCHOK mod.__getattr__ 3.7+
55_WARNINGS_X_DEV = _envPYGEODESY('WARNINGS') and (_PYTHON_X_DEV or bool(_sys.warnoptions)) # PYCHOK .props
57# @module_property[_RO?] <https://GitHub.com/jtushman/proxy_tools/> <https://discuss.Python.org/t/47379>
58isLazy = None # see @var isLazy in .__init__
61class LazyAttributeError(AttributeError):
62 '''Raised if a C{lazily imported} attribute is missing or invalid.
63 '''
64 def __init__(self, *args, **kwds):
65 _ALL_MODS.errors._error_init(AttributeError, self, args, **kwds)
68class LazyImportError(ImportError):
69 '''Raised if C{lazy import} is not supported, disabled or failed.
70 '''
71 def __init__(self, *args, **kwds):
72 _ALL_MODS.errors._error_init(ImportError, self, args, **kwds)
75class _Dict(dict):
76 '''(INTERNAL) Imports C{dict}.
77 '''
78 _name = NN
80 def __getattr__(self, attr):
81 try:
82 return self[attr]
83 except KeyError:
84 return dict.__getattr__(self, attr)
86# def __setattr__(self, attr, value):
87# if attr in self:
88# self[attr] = value
89# else:
90# dict.__setattr__(self, attr, value)
92 def add(self, name, mod_, *subs):
93 '''Add a C{[name] = mod_} item.
95 @raise AssertionError: The B{C{name}} already exists
96 with a different B{C{mod_}}.
97 '''
98 try:
99 sub = self[name] # duplicate OK
100 if sub != mod_ and sub not in subs:
101 t = _DOT_(self._name, name)
102 t = _COLONSPACE_(t, repr(sub))
103 t = _COMMASPACE_(t, _not_(repr(mod_)))
104 raise AssertionError(t)
105 except KeyError:
106 self[name] = mod_
108 def _NAME(self, which):
109 self._name = _intern(typename(which).upper())
112class _NamedEnum_RO(dict):
113 '''(INTERNAL) C{Read_Only} enum-like C{dict} sub-class.
114 '''
115# _name = NN # also first kwd, __init__(_name=...)
117 def _DOT_(self, attr): # PYCHOK no cover
118 return _DOT_(self._name, attr) # PYCHOK _name
120 def __getattr__(self, attr):
121 try:
122 return self[attr]
123 except KeyError:
124 t = self._DOT_(attr)
125 raise LazyAttributeError(t, txt=_doesn_t_exist_)
127 def __setattr__(self, attr, value): # PYCHOK no cover
128 t = _EQUALSPACED_(self._DOT_(attr), repr(value))
129 raise LazyAttributeError(_immutable_, txt=t)
131 def enums(self):
132 # Yield all C{(mod_, tuple)} pairs
133 for m, t in dict.items(self):
134 n = m.replace(_UNDER_, _DOT_)
135 if n != m:
136 if m.startswith(_UNDER_):
137 continue # skip _name= ...
138 u = m.rstrip(_UNDER_)
139 if u != m:
140 u = len(u)
141 n = n[:u] + m[u:]
142 yield n, t
144 def fill_D(self, _D, which):
145 # Fill C{_Dict _D}.
146 _D._NAME(which)
147 _a = _D.add
148 for m, t in self.enums():
149 _a(m, _DOT_(m, NN, NN)) # import module
150 for a in t:
151 a, _, as_ = a.partition(_asSPACED_)
152 if as_: # import attr as attr_
153 _a(as_, _DOT_(m, a, NN), *_SUB_PACKAGES)
154 else:
155 _a(a, m)
156 return _D
159def _a(*names):
160 '''(INTERNAL) Intern all C{names}.
161 '''
162 return tuple(map(_intern, names)) if names else _a0
165def _ALL_ATTRS(*attrs):
166 '''(INTERNAL) Unravel all exported module attributes.
167 '''
168 t = ()
169 for attr in attrs:
170 t += tuple(map(_getattras, attr))
171 return t
174_ALL_INIT = _a(_pygeodesy_abspath_, _version_)
176# __all__ value for most modules, accessible as _ALL_LAZY.<module>
177_ALL_LAZY = _NamedEnum_RO(_name='_ALL_LAZY',
178 albers=_a('AlbersEqualArea', 'AlbersEqualArea2', 'AlbersEqualArea4',
179 'AlbersEqualAreaCylindrical', 'AlbersEqualAreaNorth', 'AlbersEqualAreaSouth',
180 'AlbersError', 'Albers7Tuple'),
181 auxilats=_a(), # module only
182 azimuthal=_a('AzimuthalError', 'Azimuthal7Tuple',
183 'Equidistant', 'EquidistantExact', 'EquidistantGeodSolve', 'EquidistantKarney',
184 'Gnomonic', 'GnomonicExact', 'GnomonicGeodSolve', 'GnomonicKarney',
185 'LambertEqualArea', 'Orthographic', 'Stereographic',
186 'equidistant', 'gnomonic'),
187 basics=_a('clips', 'copysign0', 'copytype', 'halfs2',
188 'int1s', 'isbool', 'isCartesian', 'isclass', 'iscomplex', 'isDEPRECATED', 'isfloat',
189 'isidentifier', 'isinstanceof', 'isint', 'isiterable', 'isiterablen', 'isiterabletype',
190 'iskeyword', 'isLatLon', 'islistuple', 'isNvector', 'isodd',
191 'isscalar', 'issequence', 'isstr', 'issubclassof', 'itemsorted',
192 'len2', 'map1', 'map2', 'max2', 'min2', 'neg', 'neg_',
193 'signBit', 'signOf', 'splice', 'str2ub', 'ub2str', 'unsigned0'),
194 booleans=_a('BooleanFHP', 'BooleanGH', 'LatLonFHP', 'LatLonGH',
195 'isBoolean'),
196 cartesianBase=_a('RadiusThetaPhi3Tuple', 'rtp2xyz', 'rtp2xyz_', 'xyz2rtp', 'xyz2rtp_'),
197 clipy=_a('ClipCS4Tuple', 'ClipFHP4Tuple', 'ClipGH4Tuple', 'ClipLB6Tuple', 'ClipSH3Tuple',
198 'clipCS4', 'clipFHP4', 'clipGH4', 'clipLB6', 'clipSH', 'clipSH3'),
199 css=_a('CassiniSoldner', 'Css', 'CSSError', 'toCss',
200 'EasNorAziRk4Tuple', 'EasNorAziRkEqu6Tuple', 'LatLonAziRk4Tuple'),
201 constants=_a('DIG', 'EPS', 'EPS0', 'EPS02', 'EPS1', 'EPS2', 'EPS4', 'EPS_2',
202 'INF', 'INT0', 'MANT_DIG', 'MAX', 'MAX_EXP', 'MIN', 'MIN_EXP', 'NAN', 'NEG0', 'NINF',
203 'PI', 'PI2', 'PI_2', 'PI3', 'PI_3', 'PI3_2', 'PI4', 'PI_4',
204 'R_FM', 'R_GM', 'R_KM', 'R_M', 'R_MA', 'R_MB', 'R_NM', 'R_QM', 'R_SM', 'R_VM',
205 'float_', 'float0_', 'isclose', 'isfinite', 'isinf', 'isint0',
206 'isnan', 'isnear0', 'isnear1', 'isnear90', 'isneg0', 'isninf', 'isnon0',
207 'remainder'),
208 datums=_a('Datum', 'Datums', 'Transform', 'Transforms'),
209# deprecated=_a(), # module only
210 dms=_a('F_D', 'F_DM', 'F_DMS', 'F_DEG', 'F_MIN', 'F_SEC', 'F_D60', 'F__E', 'F__F', 'F__G', 'F_RAD',
211 'F_D_', 'F_DM_', 'F_DMS_', 'F_DEG_', 'F_MIN_', 'F_SEC_', 'F_D60_', 'F__E_', 'F__F_', 'F__G_', 'F_RAD_',
212 'F_D__', 'F_DM__', 'F_DMS__', 'F_DEG__', 'F_MIN__', 'F_SEC__', 'F_D60__', 'F__E__', 'F__F__', 'F__G__', 'F_RAD__',
213 'S_DEG', 'S_MIN', 'S_SEC', 'S_DMS', 'S_RAD', 'S_SEP',
214 'bearingDMS', 'clipDegrees', 'clipRadians', 'compassDMS', 'compassPoint',
215 'degDMS', 'latDMS', 'latlonDMS', 'latlonDMS_', 'lonDMS', 'normDMS',
216 'parseDDDMMSS', 'parseDMS', 'parseDMS2', 'parse3llh', 'parseRad', 'precision', 'toDMS'),
217 ecef=_a('EcefError', 'EcefFarrell21', 'EcefFarrell22', 'EcefKarney', 'EcefMatrix',
218 'EcefSudano', 'Ecef9Tuple', 'EcefVeness', 'EcefYou'),
219 ecefLocals=_a(), # module only
220 elevations=_a('Elevation2Tuple', 'GeoidHeight2Tuple',
221 'elevation2', 'geoidHeight2'),
222 ellipsoidalBase=_a(), # module only
223 ellipsoidalBaseDI=_a(), # module only
224 ellipsoidalExact=_a(), # module only
225 ellipsoidalGeodSolve=_a(), # module only
226 ellipsoidalKarney=_a(), # module only
227 ellipsoidalNvector=_a(), # module only
228 ellipsoidalVincenty=_a('VincentyError',), # nothing else
229 ellipsoids=_a('a_f2Tuple', 'Circle4Tuple', 'Curvature2Tuple',
230 'Ellipsoid', 'Ellipsoid2', 'Ellipsoids',
231 'a_b2e', 'a_b2e2', 'a_b2e22', 'a_b2e32', 'a_b2f', 'a_b2f_', 'a_b2f2', 'a_b2n',
232 'a_f2b', 'a_f_2b', 'b_f2a', 'b_f_2a',
233 'e2f', 'e22f',
234 'f2e2', 'f2e22', 'f2e32', 'f_2f', 'f2f_', 'f2f2', 'f2n', 'n2e2', 'n2f', 'n2f_'),
235 elliptic=_a('Elliptic', 'EllipticError', 'Elliptic3Tuple'),
236 epsg=_a('Epsg', 'EPSGError'),
237 errors=_a('AuxError', 'ClipError', 'CrossError', 'GeodesicError', 'IntersectionError',
238 'NumPyError', 'LenError', 'LimitError', 'MGRSError',
239 'ParseError', 'PointsError', 'RangeError', 'RhumbError',
240 'SciPyError', 'SciPyWarning', 'TRFError', 'TriangleError', 'UnitError', 'VectorError',
241 'crosserrors', 'exception_chaining', 'isError', 'limiterrors', 'rangerrors'),
242 etm=_a('Etm', 'ETMError', 'ExactTransverseMercator',
243 'parseETM5', 'toEtm8'),
244 fmath=_a('Fdot', 'Fdot_', 'Fhorner', 'Fhypot', 'Fpolynomial', 'Fpowers', 'Fcbrt', 'Froot', 'Fsqrt',
245 'bqrt', 'cbrt', 'cbrt2', 'euclid', 'euclid_',
246 'facos1', 'fasin1', 'fatan', 'fatan1', 'fatan2', 'favg',
247 'fdot', 'fdot_', 'fdot3', 'fma', 'fmean', 'fmean_', 'fhorner', 'fidw', 'f2mul_',
248 'fpolynomial', 'fpowers', 'fprod', 'frandoms', 'frange', 'freduce', 'fremainder',
249 'hypot', 'hypot_', 'hypot1', 'hypot2', 'hypot2_',
250 'norm2', 'norm_', 'sqrt0', 'sqrt3', 'sqrt_a', 'zcrt', 'zqrt'),
251 formy=_a('Radical2Tuple',
252 'angle2chord', 'antipode', 'antipode_', 'bearing', 'bearing_',
253 'chord2angle', 'compassAngle', 'cosineLaw', 'cosineLaw_',
254 'equirectangular', 'equirectangular4', 'euclidean', 'euclidean_',
255 'excessAbc_', 'excessCagnoli_', 'excessGirard_', 'excessLHuilier_',
256 'excessKarney', 'excessKarney_', 'excessQuad', 'excessQuad_',
257 'flatLocal', 'flatLocal_', 'flatPolar', 'flatPolar_',
258 'hartzell', 'haversine', 'haversine_', 'heightOf', 'heightOrthometric', 'horizon', 'hubeny', 'hubeny_',
259 'intersection2', 'intersections2', 'isantipode', 'isantipode_', 'isnormal', 'isnormal_',
260 'normal', 'normal_', 'opposing', 'opposing_', 'radical2',
261 'thomas', 'thomas_', 'vincentys', 'vincentys_'),
262 frechet=_a('Frechet', 'FrechetDegrees', 'FrechetError', 'FrechetRadians', 'FrechetCosineLaw',
263 'FrechetDistanceTo', 'FrechetEquirectangular', 'FrechetEuclidean', 'FrechetExact',
264 'FrechetFlatLocal', 'FrechetFlatPolar', 'FrechetHaversine', 'FrechetHubeny', 'FrechetKarney',
265 'FrechetThomas', 'FrechetVincentys', 'Frechet6Tuple',
266 'frechet_'),
267 fstats=_a('Fcook', 'Flinear', 'Fwelford'),
268 fsums=_a('Fsum', 'DivMod2Tuple', 'Fsum2Tuple', 'ResidualError',
269 'f2product', 'fsum', 'fsum_', 'fsumf_', 'fsum1', 'fsum1_', 'fsum1f_', 'nonfiniterrors'),
270 gars=_a('Garef', 'GARSError'),
271 geodesici=_a('Intersectool', 'Intersectool5Tuple', 'Intersect7Tuple',
272 'Intersector', 'Intersector5Tuple', 'Middle5Tuple', 'XDict'),
273 geodesicw=_a('Geodesic', 'GeodesicLine', 'Geodesic_WGS84'),
274 geodesicx=_a('gx', 'gxarea', 'gxbases', 'gxline', # modules
275 'GeodesicAreaExact', 'GeodesicExact', 'GeodesicLineExact', 'PolygonArea'),
276 geodsolve=_a('GeodesicSolve', 'GeodesicLineSolve', 'GeodSolve12Tuple'),
277 geohash=_a('Geohash', 'Geohashed', 'GeohashError', 'Neighbors8Dict', 'Resolutions2Tuple', 'Sizes3Tuple'),
278 geoids=_a('GeoidError', 'GeoidEGM96', 'GeoidG2012B', 'GeoidKarney', 'GeoidPGM', 'egmGeoidHeights',
279 'PGMError', 'GeoidHeight5Tuple'),
280 hausdorff=_a('Hausdorff', 'HausdorffDegrees', 'HausdorffError', 'HausdorffRadians', 'HausdorffCosineLaw',
281 'HausdorffDistanceTo', 'HausdorffEquirectangular', 'HausdorffEuclidean', 'HausdorffExact',
282 'HausdorffFlatLocal', 'HausdorffFlatPolar', 'HausdorffHaversine', 'HausdorffHubeny',
283 'HausdorffKarney', 'HausdorffThomas', 'HausdorffVincentys', 'Hausdorff6Tuple',
284 'hausdorff_', 'randomrangenerator'),
285 heights=_a('HeightCubic', 'HeightError', 'HeightIDWcosineLaw', 'HeightIDWdistanceTo',
286 'HeightIDWequirectangular', 'HeightIDWeuclidean', 'HeightIDWexact', 'HeightIDWflatLocal',
287 'HeightIDWflatPolar', 'HeightIDWhaversine', 'HeightIDWhubeny', 'HeightIDWkarney', 'HeightIDWthomas',
288 'HeightIDWvincentys', 'HeightLinear', 'HeightLSQBiSpline', 'HeightSmoothBiSpline'),
289 internals=_internals.__all__,
290 interns=_interns.__all__,
291 iters=_a('LatLon2PsxyIter', 'PointsIter', 'points2',
292 'isNumpy2', 'isPoints2', 'isTuple2', 'iterNumpy2', 'iterNumpy2over'),
293 karney=_a('Area3Tuple', 'Caps', 'Direct9Tuple', 'GDict', 'Inverse10Tuple', 'Rhumb8Tuple'),
294 ktm=_a('KTMError', 'KTransverseMercator'),
295 latlonBase=_a('latlon2n_xyz', 'philam2n_xyz'),
296 lazily=_a('LazyAttributeError', 'LazyImportError', 'isLazy'),
297 lcc=_a('Conic', 'Conics', 'Lcc', 'LCCError', 'toLcc'),
298 ltp=_a('Attitude', 'AttitudeError', 'ChLV', 'ChLVa', 'ChLVe', 'Frustum',
299 'LocalCartesian', 'LocalError', 'Ltp', 'tyr3d'),
300 ltpTuples=_a('Aer', 'Aer4Tuple', 'Attitude4Tuple',
301 'ChLVEN2Tuple', 'ChLV9Tuple', 'ChLVYX2Tuple', 'ChLVyx2Tuple',
302 'Enu', 'Enu4Tuple', 'Footprint5Tuple', 'Local9Tuple', 'Los',
303 'Ned', 'Ned4Tuple', 'Uvw', 'Uvw3Tuple', 'XyzLocal', 'Xyz4Tuple'),
304 mgrs=_a('Mgrs', 'parseMGRS', 'toMgrs', 'Mgrs4Tuple', 'Mgrs6Tuple'),
305 named=_a('ADict',
306 'callername', 'classname', 'classnaming', 'modulename',
307 'nameof', 'notImplemented', 'notOverloaded'),
308 namedTuples=_a('Bearing2Tuple', 'Bounds2Tuple', 'Bounds4Tuple',
309 'Destination2Tuple', 'Destination3Tuple',
310 'Distance2Tuple', 'Distance3Tuple', 'Distance4Tuple',
311 'EasNor2Tuple', 'EasNor3Tuple', 'Forward4Tuple', 'Intersection3Tuple',
312 'LatLon2Tuple', 'LatLon3Tuple', 'LatLon4Tuple',
313 'LatLonDatum3Tuple', 'LatLonDatum5Tuple',
314 'LatLonPrec3Tuple', 'LatLonPrec5Tuple',
315 'NearestOn2Tuple', 'NearestOn3Tuple', 'NearestOn6Tuple', 'NearestOn8Tuple',
316 'PhiLam2Tuple', 'PhiLam3Tuple', 'PhiLam4Tuple', 'Point3Tuple', 'Points2Tuple',
317 'Reverse4Tuple', 'Triangle7Tuple', 'Triangle8Tuple', 'Trilaterate5Tuple',
318 'UtmUps2Tuple', 'UtmUps5Tuple', 'UtmUps8Tuple', 'UtmUpsLatLon5Tuple',
319 'Vector2Tuple', 'Vector3Tuple', 'Vector4Tuple'),
320 nvectorBase=_a('NorthPole', 'SouthPole', 'n_xyz2latlon', 'n_xyz2philam'),
321 osgr=_a('Osgr', 'OSGRError', 'parseOSGR', 'toOsgr'),
322 points=_a('LatLon_', 'LatLon2psxy', 'Numpy2LatLon', 'Shape2Tuple', 'Tuple2LatLon',
323 'areaOf', 'boundsOf', 'centroidOf', 'fractional',
324 'isclockwise', 'isconvex', 'isconvex_', 'isenclosedBy', 'ispolar',
325 'luneOf', 'nearestOn5', 'perimeterOf', 'quadOf'),
326 props=_a('Property', 'Property_RO', 'property_doc_',
327 'property_RO', 'property_ROnce', 'property_ROver',
328 'deprecated_class', 'deprecated_function', 'deprecated_method',
329 'deprecated_Property_RO', 'deprecated_property_RO', 'DeprecationWarnings'),
330 resections=_a('Collins5Tuple', 'ResectionError', 'Survey3Tuple', 'Tienstra7Tuple',
331 'TriAngle5Tuple', 'TriSide2Tuple', 'TriSide4Tuple',
332 'cassini', 'collins5', 'pierlot', 'pierlotx', 'tienstra7',
333 'snellius3', 'wildberger3',
334 'triAngle', 'triAngle5', 'triArea', 'triSide', 'triSide2', 'triSide4'),
335 rhumb=_a(), # module only
336 rhumb_aux_=_a('RhumbAux', 'RhumbLineAux'),
337 rhumb_ekx=_a('Rhumb', 'RhumbLine'),
338 rhumb_solve=_a('RhumbSolve', 'RhumbLineSolve', 'RhumbSolve7Tuple'),
339 sphericalBase=_a(), # module only
340 sphericalNvector=_a(), # module only
341 sphericalTrigonometry=_a(), # module only
342 simplify=_a('simplify1', 'simplifyRDP', 'simplifyRW', 'simplifyVW'),
343 solveBase=_a(), # module only
344 streprs=_a('anstr', 'attrs', 'enstr2', 'fstr', 'fstrzs', 'hstr', 'instr',
345 'lrstrip', 'pairs', 'reprs', 'strs', 'unstr'),
346 trf=_a('RefFrame', 'RefFrames', 'TransformXform', 'TRFXform', 'TRFXform7Tuple',
347 'date2epoch', 'epoch2date', 'trfTransform0', 'trfTransforms', 'trfXform'),
348 triaxials=_a('BetaOmega2Tuple', 'BetaOmega3Tuple', 'Jacobi2Tuple',
349 'JacobiConformal', 'JacobiConformalSpherical',
350 'Triaxial', 'Triaxial_', 'TriaxialError', 'Triaxials', 'hartzell4'),
351 units=_a('Azimuth', 'Band', 'Bearing', 'Bearing_', 'Bool',
352 'Degrees', 'Degrees_', 'Degrees2', 'Distance', 'Distance_', 'Easting', 'Epoch',
353 'Feet', 'FIx', 'Float_', 'Height', 'Height_', 'HeightX', 'Int_',
354 'Lam', 'Lamd', 'Lat', 'Lat_', 'Lon', 'Lon_',
355 'Meter', 'Meter_', 'Meter2', 'Meter3', 'Northing', 'Number_',
356 'Phi', 'Phid', 'Precision_', 'Radians', 'Radians_', 'Radians2',
357 'Radius_', 'Scalar', 'Scalar_', 'Zone'),
358 unitsBase=_a('Float', 'Int', 'Radius', 'Str'),
359 ups=_a('Ups', 'UPSError', 'parseUPS5', 'toUps8', 'upsZoneBand5'),
360 utily=_a('acos1', 'acre2ha', 'acre2m2', 'asin1', 'atan1', 'atan1d', 'atan2', 'atan2b', 'atan2d',
361 'chain2m', 'circle4', 'cot', 'cot_', 'cotd', 'cotd_',
362 'degrees', 'degrees90', 'degrees180', 'degrees360', 'degrees2grades', 'degrees2m',
363 'fathom2m', 'ft2m', 'furlong2m', # 'degrees2grades as degrees2gons',
364 'grades', 'grades400', 'grades2degrees', 'grades2radians',
365# 'grades as gons', 'grades400 as gons400', 'grades2degrees as gons2degrees', 'grades2radians as gons2radians',
366 'ha2acre', 'ha2m2', 'hav', 'km2m',
367 'm2acre', 'm2chain', 'm2degrees', 'm2fathom', 'm2ft', 'm2furlong',
368 'm2ha', 'm2km', 'm2NM', 'm2radians', 'm2SM', 'm2toise', 'm2yard',
369 'NM2m', 'radians', 'radiansPI', 'radiansPI2', 'radiansPI_2', 'radians2m',
370 'sincos2', 'SinCos2', 'sincos2_', 'sincos2d', 'sincos2d_', 'sincostan3', 'sincostan3d', 'SM2m',
371 'tan', 'tan_', 'tand', 'tand_', 'tan_2', 'tanPI_2_2', 'toise2m', 'truncate',
372 'unroll180', 'unrollPI',
373 'wrap90', 'wrap180', 'wrap360', 'wrapPI_2', 'wrapPI', 'wrapPI2', 'wrap_normal',
374 'yard2m'),
375 utm=_a('Utm', 'UTMError', 'parseUTM5', 'toUtm8', 'utmZoneBand5'),
376 utmups=_a('UtmUps', 'UTMUPSError', 'parseUTMUPS5', 'toUtmUps8',
377 'utmupsValidate', 'utmupsValidateOK', 'utmupsZoneBand5'),
378 utmupsBase=_a(), # module only
379 vector2d=_a('Circin6Tuple', 'Circum3Tuple', 'Circum4Tuple', 'Meeus2Tuple', 'Radii11Tuple', 'Soddy4Tuple', 'Triaxum5Tuple',
380 'circin6', 'circum3', 'circum4', 'circum4_', 'meeus2', 'radii11', 'soddy4', 'triaxum5', 'trilaterate2d2'),
381 vector3d=_a('Vector3d', 'intersection3d3', 'iscolinearWith', 'nearestOn', 'nearestOn6', 'parse3d',
382 'trilaterate3d2'),
383 vector3dBase=_a(), # module only
384 webmercator=_a('Wm', 'WebMercatorError', 'parseWM', 'toWm', 'EasNorRadius3Tuple'),
385 wgrs=_a('Georef', 'WGRSError'),)
387_ALL_DEPRECATED = _NamedEnum_RO(_name='_ALL_DEPRECATED',
388 deprecated=_a('bases', 'datum', 'nvector', # DEPRECATED modules and ...
389 'rhumbaux', 'rhumbBase', 'rhumbsolve', 'rhumbx'), # ... names
390 deprecated_bases=_a('LatLonHeightBase', 'points2'),
391 deprecated_classes=_a('ClipCS3Tuple', 'EasNorExact4Tuple', 'EcefCartesian', 'Fn_rt',
392 'FrechetCosineAndoyerLambert', 'FrechetCosineForsytheAndoyerLambert',
393 'HausdorffCosineAndoyerLambert', 'HausdorffCosineForsytheAndoyerLambert',
394 'HeightIDW', 'HeightIDW2', 'HeightIDW3', 'HeightIDWcosineAndoyerLambert',
395 'HeightIDWcosineForsytheAndoyerLambert', 'Helmert7Tuple',
396 'Lam_', 'LatLonExact4Tuple', 'NearestOn4Tuple', 'Ned3Tuple',
397 'Phi_', 'RefFrameError', 'Rhumb7Tuple', 'RhumbOrder2Tuple',
398 'Transform7Tuple', 'TriAngle4Tuple', 'UtmUps4Tuple', 'XDist'),
399 deprecated_consterns=_a('EPS1_2', 'MANTIS', 'OK'),
400 deprecated_datum=_a('Curvature2Tuple', 'Datum', 'Ellipsoid', 'Transform', # assert
401 'Datums', 'Ellipsoids', 'Transforms',
402 'R_FM', 'R_KM', 'R_M', 'R_MA', 'R_MB', 'R_NM', 'R_SM', 'R_VM'),
403 deprecated_functions=_a('anStr', 'areaof', 'atand', 'bounds', # most of the DEPRECATED functions, except ellipsoidal ...
404 'clipCS3', 'clipDMS', 'clipStr', 'collins', 'copysign', # ... and spherical flavors
405 'cosineAndoyerLambert', 'cosineAndoyerLambert_',
406 'cosineForsytheAndoyerLambert', 'cosineForsytheAndoyerLambert_',
407 'decodeEPSG2', 'encodeEPSG', 'enStr2', 'equirectangular_', 'equirectangular3',
408 'excessAbc', 'excessGirard', 'excessLHuilier',
409 'false2f', 'falsed2f', 'float0', 'fStr', 'fStrzs', 'Fsum2product',
410 'hypot3', 'inStr', 'isenclosedby', 'istuplist',
411 'joined', 'joined_', 'nearestOn3', 'nearestOn4',
412 'parseUTM', 'perimeterof', 'polygon',
413 'scalar', 'simplify2', 'simplifyRDPm', 'simplifyVWm',
414 'tienstra', 'toUtm', 'triAngle4',
415 'unsign0', 'unStr', 'utmZoneBand2'),
416 deprecated_nvector=_a('LatLonNvectorBase', 'Nvector', 'sumOf', 'NorthPole', 'SouthPole'),)
419class _ALL_MODS(_internals._MODS_Base):
420 '''(INTERNAL) Memoized import of any L{pygeodesy} module.
421 '''
422 def __getattr__(self, name):
423 '''Get a C{pygeodesy} module or attribute by B{C{name}}.
425 @arg name: Un/qualified module or qualified attribute name (C{str}).
427 @raise ImportError: Importing module B{C{name}} failed.
429 @raise AttributeError: No attribute named B{C{name}}.
430 '''
431 try:
432 v = _lazy_dict[name] # package.__dict__
433 except KeyError:
434 v = _lazy_module(name) # package.__getattr__
435 if _tailof(typename(v)) != name:
436 try:
437 v = getattr(v, _tailof(name))
438 except AttributeError:
439 pass # XXX LazyAttributeError?
440 return v
442 def getattr(self, name, *attr_dflt): # , parent=_pygeodesy_
443 '''Get an attribute of/or a C{pygeodesy} module.
445 @arg name: Un/qualified module name (C{str}).
446 @arg attr_dflt: Optional attribute name (C{str}) and
447 optional default value (any C{type}).
449 @return: The C{pygeodesy} module's attribute value.
451 @raise ImportError: Importing module B{C{name}} failed.
453 @raise AttributeError: No attribute named B{C{attr}}.
454 '''
455 v = self.getmodule(name)
456 if attr_dflt:
457 v = getattr(v, *attr_dflt)
458 return v
460 def getmodule(self, name, parent=_pygeodesy_):
461 '''Get a C{pygeodesy} module or the C{__main__}.
463 @arg name: Un/qualified module name (C{str}).
465 @return: The C{pygeodesy} module.
467 @raise ImportError: Importing module B{C{name}} failed.
468 '''
469 if _headof(name) != parent and name != _DMAIN_:
470 name = _DOT_(parent, name)
471 try:
472 return _sys.modules[name]
473 except KeyError:
474 return _getmodule(name, parent)
476 def imported(self, name):
477 '''Return module or package C{name} if already imported.
478 '''
479 return _sys.modules.get(name, None)
481 def into(self, **mod_DNAME):
482 '''Deferred import of module C{mod} into module C{_DNAME_}
483 and overwrite C{_DNAME_._mod} to module C{mod}, I{once}
484 at the first access of an attribute of module C{mod}.
485 '''
486 # assert len(mod_DNAME) == 1
487 # mod, dun = mod_DNAME.popitem()
489 class _Into(object):
491 def __getattr__(unused, name):
492 m = _getmodinto(mod_DNAME, _Into)
493 return getattr(m, name)
495 return _Into()
497# @_Property_RO
498# def _isBoolean(self):
499# '''(INTERNAL) Get function C(.booleans.isBoolean}, I{once}.
500# '''
501# return self.booleans.isBoolean
503 def items(self): # no module named 'items'
504 '''Yield the modules imported so far.
505 '''
506 for n, m in _sys.modules.items():
507 if _headof(n) == _pygeodesy_:
508 yield n, m
510_internals._MODS = _ALL_MODS = _ALL_MODS() # PYCHOK singleton
512__all__ = _ALL_LAZY.lazily
513__version__ = '25.05.19'
516def _ALL_OTHER(*objs):
517 '''(INTERNAL) Get class and function B{C{objs}} for __all__.
518 '''
519 def _interned(o): # intern'd base name
520 n = _tailof(typename(o))
521 i = NN(_UNDER_, n, _UNDER_) # intern'd
522 return getattr(_interns, i, n)
524 return tuple(map(_interned, objs)) # map2
527if _FOR_DOCS: # PYCHOK no cover
528 _ALL_DOCS = _ALL_OTHER
529 # (INTERNAL) Only export B{C{objs.__name__}} when making the
530 # docs to force C{epydoc} to include certain classes, methods,
531 # functions and other names in the documentation. Using the
532 # C{epydoc --private ...} command line option tends to include
533 # too much internal documentation.
534else:
535 def _ALL_DOCS(*unused):
536 return ()
539def _all_deprecates():
540 '''(INTERNAL) Build C{dict} of all deprecated imports and attributes.
541 '''
542 D = _ALL_DEPRECATES
543 if not D:
544 _ALL_DEPRECATED.fill_D(D, _all_deprecates) # see _all_imports()
545 return D
547_ALL_DEPRECATES = _Dict() # PYCHOK _ALL_DEPRECATED.imports()
550def _all_enums():
551 '''(INTERNAL) Yield all C{(mod_, tuple)} pairs for C{__init__._all}.
552 '''
553 # assert _init__all__
554 for mod_t in _ALL_LAZY.enums():
555 yield mod_t
556 if _FOR_DOCS:
557 for mod_t in _ALL_DEPRECATED.enums():
558 yield mod_t
561def _all_imports():
562 '''(INTERNAL) Build C{dict} of all lazy imports.
563 '''
564 # imports naming conventions stored below - [<key>] = <from>:
565 # import <module> - [<module>] = <module>
566 # from <module> import <attr> - [<attr>] = <module>
567 # from pygeodesy import <attr> - [<attr>] = <attr>
568 # from <module> import <attr> as <name> - [<name>] = <module>.<attr>.
569 D = _ALL_IMPORTS
570 if not D:
571 _ALL_LAZY.fill_D(D, _all_imports) # see _all_deprecates()
572 return D
574_ALL_IMPORTS = _Dict() # PYCHOK _ALL_LAZY.imports()
577def _all_missing2(_all_):
578 '''(INTERNAL) Get diffs between pygeodesy.__all__ and lazily._all_imports.
579 '''
580 def _diff(one, two):
581 return tuple(sorted(a for a in one if a not in two))
583 _alzy = _Dict((a, a) for a in _ALL_INIT)
584 _alzy.update(_all_imports()) # without _all_backups!
585 return ((_DOT_(_lazily_, _all_imports.__name__), _diff(_all_, _alzy)),
586 (_DOT_(_pygeodesy_, _DALL_), _diff(_alzy.keys(), _all_)))
589def _getattras(attr_as): # test/testDeprecated
590 '''(INTERNAL) Get the C{"as name"} or C{"name"} of a lazy entry.
591 '''
592 a_, _, as_ = attr_as.partition(_asSPACED_)
593 return as_ or a_.rstrip(_DOT_)
596def _getmodattr(m, name, mod=_pygeodesy_):
597 '''(INTERNAL) Get attr C{m.name}.
598 '''
599 try:
600 return getattr(m, name)
601 except AttributeError:
602 name = _DOT_(typename(m, mod), name)
603 # <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
604 raise LazyAttributeError(_no_(_attribute_), txt=name)
607def _getmodinto(mod_DNAME, *Intos):
608 '''(INTERNAL) Core of C{_ALL_MODS.into}.
609 '''
610 _MODS = _ALL_MODS
611 mod, dun = _MODS.errors._xkwds_item2(mod_DNAME)
612 _mod = _UNDER_(NN, mod)
613 d = _MODS.getmodule(dun) # '__main__' OK
614 i = _getmodattr(d, _mod, dun)
615 assert isinstance(i, Intos)
616 m = _MODS.getmodule(mod)
617 setattr(d, _mod, m) # overwrite C{d._mod}
618 if isLazy > 1:
619 t = _SPACE_(_HASH_, _imported_, m.__name__) # typename(m)
620 _hash_imported(t, _MODS.into.__name__)
621 assert getattr(d, _mod, None) is m
622 return m
625def _getmodule(name, *parent):
626 '''(INTERNAL) Wrapper for C{import_module}.
627 '''
628 try:
629 return import_module(name, parent)
630 except ImportError:
631 # <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
632 raise LazyImportError(_no_(_module_), txt=name)
635def _hash_imported(t, by_into, up=3):
636 '''(INTERNAL) Helper for C{_lazy_import2} and C{_ALL_MODS.into}.
637 '''
638 if isLazy > 2:
639 try: # see C{internals._caller3}
640 _, f, s = _caller3(up)
641 t = _SPACE_(t, by_into, f, _line_, s)
642 except ValueError:
643 pass
644 printf(t) # XXX print
647# def _lazy_attributes(DUNDER_name):
648# '''(INTERNAL) Return a function to C{B{__name__}.__getattr__(attr)}
649# on lazily imported modules and sub-modules.
650# '''
651# if _unlazy:
652# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
653#
654# def _getattr(attr, *dflt):
655# try: # a module name
656# return _ALL_MODS.getmodule(attr)
657# except (AttributeError, ImportError):
658# return _ALL_MODS.getattr(DUNDER_name, attr, *dflt)
659#
660# return _getattr
663_lazy_dict = {} # PYCHOK overwritten by _lazy_import2
666def _lazy_import2(pack): # MCCABE 14
667 '''Check for and set up C{lazy import}.
669 @arg pack: The name of the package (C{str}) performing the imports,
670 to help resolving relative imports, usually C{__package__}.
672 @return: 2-Tuple C{(package, getattr)} of the importing package for
673 easy reference within itself and the callable to be set to
674 C{package.__getattr__}.
676 @raise LazyAttributeError: The package, module or attribute name is
677 invalid or does not exist.
679 @raise LazyImportError: Lazy import not supported or not enabled or
680 an import failed.
682 @note: This is I{Brett Cannon}'s function U{modutil.lazy_import
683 <https://GitHub.com/brettcannon/modutil/blob/master/modutil.py>}
684 modified to handle the C{__all__} and C{__dir__} attributes and
685 call C{importlib.import_module(<module>.<name>, ...)} without
686 causing a C{ModuleNotFoundError}.
688 @see: The original U{modutil<https://PyPI.org/project/modutil>},
689 U{PEP 562<https://www.Python.org/dev/peps/pep-0562>} and the
690 U{new way<https://Snarky.CA/lazy-importing-in-python-3-7/>}.
691 '''
692 if pack != _pygeodesy_ or _unlazy: # Python 3.7+ # PYCHOK no cover
693 t = _DOT_(pack, typename(_lazy_import2))
694 raise LazyImportError(_no_(t), txt=_versions())
696 package, parent = _lazy_init2(pack) # _pygeodesy_
698 _DPACKAGE_ = '__package__'
699 _lazily_imported_ = _SPACE_(_HASH_, _lazily_, _imported_, parent)
701 sub_packages = set((parent, NN) + tuple(
702 _DOT_(parent, s) for s in _SUB_PACKAGES))
703 imports = _all_imports()
704 deprecates = _all_deprecates()
706 def __getattr__(name): # __getattr__ only for Python 3.7+
707 # only called once for each undefined pygeodesy attribute
708 mod = imports.get(name, NN) or deprecates.get(name, NN)
709 if mod:
710 # importlib.import_module() implicitly sets sub-modules
711 # on this module as appropriate for direct imports (see
712 # note in the _lazy_import2.__doc__ above).
713 if mod.endswith(_DOT_): # import mod[.attr] as name
714 mod, _, attr = mod[:-1].rpartition(_DOT_)
715 else: # from mod import name
716 attr = name
717 v = _getmodule(_DOT_(pack, mod), parent)
718 t = getattr(v, _DPACKAGE_, None)
719 if t not in sub_packages: # invalid module package
720 raise LazyImportError(_DOT_(mod, _DPACKAGE_), t)
721 if attr: # get mod.attr
722 v = _getmodattr(v, attr, mod)
724 elif name in (_DALL_,): # XXX _Ddir_, _Dmembers_?
725 v = _ALL_INIT + tuple(imports.keys())
726 else: # PYCHOK no cover
727 t = _no_(_module_, _or_, _attribute_)
728 # <https://GitHub.com/mrJean1/PyGeodesy/issues/76>
729 raise LazyAttributeError(t, txt=_DOT_(parent, name))
731 setattr(package, name, v) # package.__dict__[name] = val
732 if isLazy > 1:
733 t = _DOT_(_lazily_imported_, name)
734 if mod and _tailof(mod) != name:
735 t = _SPACE_(t, _from_, _DOT_(NN, mod))
736 _hash_imported(t, _by_)
738 return v # __getattr__
740 global _lazy_dict, _lazy_module
741 _lazy_dict = package.__dict__
742 _lazy_module = __getattr__
744 return package, __getattr__ # _lazy_import2
747# def _lazy_import_all(Dname):
748# '''(INTERNAL) Return a function mimicking C{from B{__name__} import *},
749# of all items, see .deprecated.__init__
750# '''
751# if _unlazy:
752# raise AssertionError(_COMMASPACE_(Dname, _not_(_DEPRECATED_)))
753#
754# _getattr = _lazy_attributes(Dname) # __name__.__getattr__
755# _import_start = _lazy_import_star(Dname, ALL_=_ALL_IMPORTS)
756#
757# def _import_all(attr, *dflt):
758# return _import_star(Dname) if attr == _DALL_ else \
759# _getattr(attr, *dflt)
760#
761# return _import_all
764def _lazy_import_as(DUNDER_name):
765 '''(INTERNAL) Return a function to C{import B{__name__}.mod as mod}
766 I{of modules only}, see .deprecated, .rhumb or get an attribute
767 lazily exported by C{__name__}.
768 '''
769 if _unlazy:
770 return None
772 def _import_as(mod):
773 try:
774 return _ALL_MODS.getmodule(_DOT_(DUNDER_name, mod))
775 except ImportError:
776 return _lazy_module(mod)
778 return _import_as
781# def _lazy_import_star(DUNDER_name, ALL_=_ALL_DEPRECATES):
782# '''(INTERNAL) Return a function to mimick C{from B{__name__} import *},
783# of all DEPRECATED items, see .deprecated, .testDeprecated
784# '''
785# if _unlazy:
786# raise AssertionError(_COMMASPACE_(DUNDER_name, _not_(_DEPRECATED_)))
787#
788# def _import_star(_into_):
789# '''Do C{from B{__name__} import *} inside module C{B{__into__}}.
790# '''
791# d = dict()
792# nm = _tailof(DUNDER_name)
793# _g = _ALL_MODS.getattr # pygeodesy.__getattr__
794# for a, m in ALL_.items():
795# if _headof(m) == nm:
796# try:
797# d[a] = _g(m, a)
798# except (AttributeError, ImportError):
799# pass
800# _sys.modules[_into_].__dict__.update(d)
801# return d.keys() # imported names
802#
803# return _import_star
806def _lazy_init2(pack):
807 '''(INTERNAL) Initialize lazy import and set globals C{isLazy} and C{_unLazy0}.
809 @arg pack: The name of the package (C{str}) performing the imports,
810 to resolve relative imports, usually C{__package__}.
812 @return: 2-Tuple C{(package, parent)} with the importing C{package}
813 for easy reference within itself and its name aka the
814 C(package)'s C{parent}, same as B{C{pack}}.
816 @raise LazyImportError: Lazy import not supported or not enabled,
817 an import failed or the package name is
818 invalid or does not exist.
820 @note: Global C{isLazy} is set accordingly.
821 '''
822 global isLazy, _unLazy0
824 E = _internals._PYGEODESY_ENV('LAZY_IMPORT')
825 z = _internals._getenv(E, _interns._1_) # 1 default on 3.7+
826 z = z.strip() # like PYTHONVERBOSE et.al.
827 isLazy = int(z) if z.isdigit() else (1 if z else 0)
829 _unLazy0 = _unlazy or not isLazy # pre-3.7 or w/o lazy import
831 if isLazy < 1: # invalid, not enabled
832 raise LazyImportError(E, repr(z), txt_not_='enabled')
833 if _sys.flags.verbose: # PYCHOK no cover
834 isLazy += 1
836 try: # to initialize in Python 3+
837 package = import_module(pack)
838 parent = package.__spec__.parent # __spec__ only in Python 3.7+
839 if parent != pack: # assert
840 t = _COMMASPACE_(parent, _not_(pack)) # PYCHOK no cover
841 raise AttributeError(_EQUALSPACED_('parent', t))
843 except (AttributeError, ImportError) as x:
844 isLazy = False # failed
845 z = typename(_lazy_init2)
846 raise LazyImportError(z, pack, cause=x)
848 return package, parent
851def _lazy_module(name): # overwritten by _lazy_import2
852 '''(INTERNAL) Get or import a C{pygeodesy} module.
853 '''
854 try: # most likely ... module has been imported
855 m = _ALL_MODS.getmodule(name)
856 except (AttributeError, ImportError) as x:
857 raise LazyImportError(name, cause=x)
858 _lazy_dict[name] = m # cache
859 return m
862# def _lazy_subs(__name__, force=_FOR_DOCS, over=False):
863# '''(INTERNAL) Return the names of a __name__ package's sub-packages
864# and update the package's C{__dict__} accordingly.
865# '''
866# sm = dict()
867# if force and __name__ != _DMAIN_:
868# nm = _tailof(__name__)
869# _a = _ALL_MODS.getattr
870# _m = _ALL_MODS.getmodule
871# d = _a(__name__, _DDICT_, {})
872# for n in _a(__name__, _DALL_, ()):
873# try: # n is a class name, get its mod name
874# m = _a(__name__, n).__module__
875# n, s = m.split(_DOT_)[-2:]
876# if n == nm and s not in sm:
877# m = _m(m) # == import m as s
878# sm[s] = m if over else d.get(s, m)
879# except (AttributeError, ImportError, ValueError) as x:
880# pass
881# d.update(sm)
882#
883# return _ALL_OTHER(*sm.values())
886if __name__ == _DMAIN_:
888 def _main():
889 from timeit import timeit
891 def t1():
892 from pygeodesy.trf import RefFrame
893 return RefFrame
895 def t2():
896 return _ALL_MODS.trf.RefFrame
898 assert t1() is t2() # prime each
900 t1 = timeit(t1, number=1000000)
901 t2 = timeit(t2, number=1000000)
902 A = typename(_ALL_MODS)
903 v = _versions()
904 printf('%.6f import vs %.6f %s: %.2fX, %s', t1, t2, A, (t1 / t2), v)
906 _main()
908# % python3.13 -W ignore -m pygeodesy.lazily
909# 0.054235 import vs 0.052469 _ALL_MODS: 1.03X, pygeodesy 25.4.24 Python 3.13.3 64bit arm64 macOS 15.4
911# % python2 -m pygeodesy.lazily
912# 0.653715 import vs 0.321318 _ALL_MODS: 2.03X, pygeodesy 25.4.24 Python 2.7.18 64bit arm64_x86_64 macOS 10.16
914# % python3.13 -W ignore -m pygeodesy.lazily
915# 0.106602 import vs 0.078136 _ALL_MODS: 1.36X, pygeodesy 24.10.24 Python 3.13.0 64bit arm64 macOS 14.6.1
917# % python3.12 -W ignore -m pygeodesy.lazily
918# 0.138844 import vs 0.080458 _ALL_MODS: 1.73X, pygeodesy 24.10.24 Python 3.12.7 64bit arm64 macOS 14.6.1
920# % python3.11 -W ignore -m pygeodesy.lazily
921# 0.387520 import vs 0.254229 _ALL_MODS: 1.52X, pygeodesy 24.10.24 Python 3.11.5 64bit arm64 macOS 14.6.1
923# % python3.10 -W ignore -m pygeodesy.lazily
924# 0.371269 import vs 0.272897 _ALL_MODS: 1.36X, pygeodesy 24.10.24 Python 3.10.8 64bit arm64 macOS 14.6.1
926# % python3.8 -W ignore -m pygeodesy.lazily
927# 0.555572 import vs 0.370304 _ALL_MODS: 1.50X, pygeodesy 24.10.24 Python 3.8.10 64bit arm64_x86_64 macOS 10.16
929# % python2 -m pygeodesy.lazily
930# 1.160292 import vs 0.490279 _ALL_MODS: 2.37X, pygeodesy 24.10.24 Python 2.7.18 64bit arm64_x86_64 macOS 10.16
932# **) MIT License
933#
934# Copyright (C) 2018-2025 -- mrJean1 at Gmail -- All Rights Reserved.
935#
936# Permission is hereby granted, free of charge, to any person obtaining a
937# copy of this software and associated documentation files (the "Software"),
938# to deal in the Software without restriction, including without limitation
939# the rights to use, copy, modify, merge, publish, distribute, sublicense,
940# and/or sell copies of the Software, and to permit persons to whom the
941# Software is furnished to do so, subject to the following conditions:
942#
943# The above copyright notice and this permission notice shall be included
944# in all copies or substantial portions of the Software.
945#
946# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
947# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
948# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
949# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
950# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
951# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
952# OTHER DEALINGS IN THE SOFTWARE.