fastcore 2.0.1__tar.gz → 2.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. {fastcore-2.0.1/fastcore.egg-info → fastcore-2.0.2}/PKG-INFO +7 -5
  2. {fastcore-2.0.1 → fastcore-2.0.2}/README.md +5 -3
  3. fastcore-2.0.2/fastcore/__init__.py +1 -0
  4. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/foundation.py +1 -1
  5. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/imports.py +1 -1
  6. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/nbio.py +2 -2
  7. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/net.py +1 -1
  8. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/xtras.py +19 -10
  9. {fastcore-2.0.1 → fastcore-2.0.2/fastcore.egg-info}/PKG-INFO +7 -5
  10. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore.egg-info/requires.txt +1 -1
  11. {fastcore-2.0.1 → fastcore-2.0.2}/pyproject.toml +1 -1
  12. fastcore-2.0.1/fastcore/__init__.py +0 -1
  13. {fastcore-2.0.1 → fastcore-2.0.2}/CONTRIBUTING.md +0 -0
  14. {fastcore-2.0.1 → fastcore-2.0.2}/LICENSE +0 -0
  15. {fastcore-2.0.1 → fastcore-2.0.2}/MANIFEST.in +0 -0
  16. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/_modidx.py +0 -0
  17. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/aio.py +0 -0
  18. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/all.py +0 -0
  19. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/ansi.py +0 -0
  20. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/basics.py +0 -0
  21. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/dispatch.py +0 -0
  22. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/docments.py +0 -0
  23. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/docscrape.py +0 -0
  24. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/imghdr.py +0 -0
  25. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/meta.py +0 -0
  26. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/nb_imports.py +0 -0
  27. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/parallel.py +0 -0
  28. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/py2pyi.py +0 -0
  29. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/script.py +0 -0
  30. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/shutil.py +0 -0
  31. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/style.py +0 -0
  32. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/test.py +0 -0
  33. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/tools.py +0 -0
  34. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/transform.py +0 -0
  35. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/utils.py +0 -0
  36. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/xdg.py +0 -0
  37. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore/xml.py +0 -0
  38. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore.egg-info/SOURCES.txt +0 -0
  39. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore.egg-info/dependency_links.txt +0 -0
  40. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore.egg-info/entry_points.txt +0 -0
  41. {fastcore-2.0.1 → fastcore-2.0.2}/fastcore.egg-info/top_level.txt +0 -0
  42. {fastcore-2.0.1 → fastcore-2.0.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
6
  License: Apache-2.0
@@ -23,7 +23,7 @@ Requires-Dist: pillow; extra == "dev"
23
23
  Requires-Dist: torch; extra == "dev"
24
24
  Requires-Dist: pandas; extra == "dev"
25
25
  Requires-Dist: nbclassic; extra == "dev"
26
- Requires-Dist: pysymbol_llm; extra == "dev"
26
+ Requires-Dist: pysymbol_llm>=0.0.6; extra == "dev"
27
27
  Requires-Dist: llms-txt; extra == "dev"
28
28
  Requires-Dist: plum-dispatch; extra == "dev"
29
29
  Requires-Dist: toolslm; extra == "dev"
@@ -67,9 +67,11 @@ and the other async utilities moved there from `xtras`.
67
67
  [`Config`](https://fastcore.fast.ai/xtras.html#config) and the config
68
68
  file functions moved from `foundation` to `xtras`. `fastcore.net` lost
69
69
  its request builders (`urlrequest`, `urlsend`, `do_request`, `urlcheck`)
70
- and `clean_type_str` is gone. `parallel_gen` moved to fastai. Python
71
- 3.11 or later is now required. If you need the old APIs, pin
72
- `fastcore<2`.
70
+ and `clean_type_str` is gone. `parallel_gen` is removed; the stdlib
71
+ [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor)
72
+ `initializer` pattern replaces it (fastai’s `parallel_tokenize` shows
73
+ the recipe). Python 3.11 or later is now required. If you need the old
74
+ APIs, pin `fastcore<2`.
73
75
 
74
76
  Python is a powerful, dynamic language. Rather than bake everything into
75
77
  the language, it lets the programmer customize it to make it work for
@@ -36,9 +36,11 @@ and the other async utilities moved there from `xtras`.
36
36
  [`Config`](https://fastcore.fast.ai/xtras.html#config) and the config
37
37
  file functions moved from `foundation` to `xtras`. `fastcore.net` lost
38
38
  its request builders (`urlrequest`, `urlsend`, `do_request`, `urlcheck`)
39
- and `clean_type_str` is gone. `parallel_gen` moved to fastai. Python
40
- 3.11 or later is now required. If you need the old APIs, pin
41
- `fastcore<2`.
39
+ and `clean_type_str` is gone. `parallel_gen` is removed; the stdlib
40
+ [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor)
41
+ `initializer` pattern replaces it (fastai’s `parallel_tokenize` shows
42
+ the recipe). Python 3.11 or later is now required. If you need the old
43
+ APIs, pin `fastcore<2`.
42
44
 
43
45
  Python is a powerful, dynamic language. Rather than bake everything into
44
46
  the language, it lets the programmer customize it to make it work for
@@ -0,0 +1 @@
1
+ __version__ = "2.0.2"
@@ -491,6 +491,6 @@ def flatten(self:L):
491
491
  "Recursively flatten nested iterables (except strings)"
492
492
  def _flatten(o):
493
493
  for item in o:
494
- if isinstance(item, (str,bytes)) or not hasattr(item,'__iter__'): yield item
494
+ if isinstance(item, strtyps) or not hasattr(item,'__iter__'): yield item
495
495
  else: yield from _flatten(item)
496
496
  return self._new(_flatten(self))
@@ -15,7 +15,7 @@ except ImportError:
15
15
  from types import BuiltinFunctionType,BuiltinMethodType,MethodType,FunctionType,SimpleNamespace
16
16
 
17
17
  NoneType = type(None)
18
- string_classes = (str,bytes)
18
+ strtyps = (str,bytes)
19
19
 
20
20
  def is_iter(o):
21
21
  "Test whether `o` can be used in a `for` loop"
@@ -96,8 +96,8 @@ def mk_cell(
96
96
  assert cell_type in {'code', 'markdown', 'raw'}
97
97
  if 'metadata' not in kwargs: kwargs['metadata']={}
98
98
  if cell_type == 'code':
99
- kwargs['outputs']=[]
100
- kwargs['execution_count']=0
99
+ kwargs.setdefault('outputs', [])
100
+ kwargs.setdefault('execution_count', None)
101
101
  return NbCell(0, dict(cell_type=cell_type, source=text, directives_={}, **kwargs))
102
102
 
103
103
  # %% ../nbs/13_nbio.ipynb #e7af3290
@@ -112,7 +112,7 @@ def urlopen(url, data=None, headers=None, timeout=None, **kwargs):
112
112
  "Like `urllib.request.urlopen`, but first `urlwrap` the `url`, and encode `data`"
113
113
  if kwargs and not data: data=kwargs
114
114
  if data is not None:
115
- if not isinstance(data, (str,bytes)): data = urlencode(data)
115
+ if not isinstance(data, strtyps): data = urlencode(data)
116
116
  if not isinstance(data, bytes): data = data.encode('ascii')
117
117
  try: return urlopener().open(urlwrap(url, data=data, headers=headers), timeout=timeout)
118
118
  except HTTPError as e:
@@ -1105,12 +1105,14 @@ def flexicache(*funcs, maxsize=128):
1105
1105
  "Like `lru_cache`, but customisable with policy `funcs`"
1106
1106
  import asyncio
1107
1107
  from collections import OrderedDict
1108
+ wants = [getattr(f, 'needs_args', False) for f in funcs]
1108
1109
  def _f(func):
1109
- cache,states = OrderedDict(), [None]*len(funcs)
1110
- def _cache_logic(key, execute_func):
1110
+ cache = OrderedDict()
1111
+ def _cache_logic(key, execute_func, args, kwargs):
1112
+ def _run(f, w, state): return f(state, args, kwargs) if w else f(state)
1111
1113
  if key in cache:
1112
1114
  result,states = cache[key]
1113
- if not any(f(state) for f,state in zip(funcs, states)):
1115
+ if not any(_run(f,w,state) for f,w,state in zip(funcs,wants,states)):
1114
1116
  cache[key] = cache.pop(key)
1115
1117
  return result
1116
1118
  del cache[key]
@@ -1119,17 +1121,17 @@ def flexicache(*funcs, maxsize=128):
1119
1121
  if key not in cache: raise
1120
1122
  cache[key] = cache.pop(key)
1121
1123
  return result
1122
- cache[key] = (newres, [f(None) for f in funcs])
1124
+ cache[key] = (newres, [_run(f,w,None) for f,w in zip(funcs,wants)])
1123
1125
  if len(cache) > maxsize: cache.popitem(last=False)
1124
1126
  return newres
1125
1127
 
1126
1128
  @wraps(func)
1127
1129
  def wrapper(*args, **kwargs):
1128
- return _cache_logic(f"{args} // {kwargs}", lambda: func(*args, **kwargs))
1130
+ return _cache_logic(f"{args} // {kwargs}", lambda: func(*args, **kwargs), args, kwargs)
1129
1131
 
1130
1132
  @wraps(func)
1131
1133
  async def async_wrapper(*args, **kwargs):
1132
- return await _cache_logic(f"{args} // {kwargs}", lambda: asyncio.ensure_future(func(*args, **kwargs)))
1134
+ return await _cache_logic(f"{args} // {kwargs}", lambda: asyncio.ensure_future(func(*args, **kwargs)), args, kwargs)
1133
1135
 
1134
1136
  return async_wrapper if asyncio.iscoroutinefunction(func) else wrapper
1135
1137
  return _f
@@ -1143,11 +1145,18 @@ def time_policy(seconds):
1143
1145
  return policy
1144
1146
 
1145
1147
  # %% ../nbs/03_xtras.ipynb #8387a8bf
1146
- def mtime_policy(filepath):
1147
- "A `flexicache` policy that expires cached items after `filepath` modified-time changes"
1148
- def policy(mtime):
1149
- current_mtime = getmtime(filepath)
1148
+ def mtime_policy(
1149
+ filepath=None, # File to watch, fixed at policy creation
1150
+ arg=None, # Or: positional index or keyword name of a call argument naming the file to watch
1151
+ ):
1152
+ "A `flexicache` policy that expires cached items after the watched file's modified-time changes"
1153
+ if (filepath is None)==(arg is None): raise TypeError('Pass exactly one of `filepath` or `arg`')
1154
+ def _expired(mtime, fp):
1155
+ current_mtime = getmtime(fp)
1150
1156
  return current_mtime if mtime is None or current_mtime>mtime else None
1157
+ if arg is None: return lambda mtime: _expired(mtime, filepath)
1158
+ def policy(mtime, args, kwargs): return _expired(mtime, kwargs[arg] if isinstance(arg,str) else args[arg])
1159
+ policy.needs_args = True
1151
1160
  return policy
1152
1161
 
1153
1162
  # %% ../nbs/03_xtras.ipynb #1094d811
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
6
  License: Apache-2.0
@@ -23,7 +23,7 @@ Requires-Dist: pillow; extra == "dev"
23
23
  Requires-Dist: torch; extra == "dev"
24
24
  Requires-Dist: pandas; extra == "dev"
25
25
  Requires-Dist: nbclassic; extra == "dev"
26
- Requires-Dist: pysymbol_llm; extra == "dev"
26
+ Requires-Dist: pysymbol_llm>=0.0.6; extra == "dev"
27
27
  Requires-Dist: llms-txt; extra == "dev"
28
28
  Requires-Dist: plum-dispatch; extra == "dev"
29
29
  Requires-Dist: toolslm; extra == "dev"
@@ -67,9 +67,11 @@ and the other async utilities moved there from `xtras`.
67
67
  [`Config`](https://fastcore.fast.ai/xtras.html#config) and the config
68
68
  file functions moved from `foundation` to `xtras`. `fastcore.net` lost
69
69
  its request builders (`urlrequest`, `urlsend`, `do_request`, `urlcheck`)
70
- and `clean_type_str` is gone. `parallel_gen` moved to fastai. Python
71
- 3.11 or later is now required. If you need the old APIs, pin
72
- `fastcore<2`.
70
+ and `clean_type_str` is gone. `parallel_gen` is removed; the stdlib
71
+ [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor)
72
+ `initializer` pattern replaces it (fastai’s `parallel_tokenize` shows
73
+ the recipe). Python 3.11 or later is now required. If you need the old
74
+ APIs, pin `fastcore<2`.
73
75
 
74
76
  Python is a powerful, dynamic language. Rather than bake everything into
75
77
  the language, it lets the programmer customize it to make it work for
@@ -7,7 +7,7 @@ pillow
7
7
  torch
8
8
  pandas
9
9
  nbclassic
10
- pysymbol_llm
10
+ pysymbol_llm>=0.0.6
11
11
  llms-txt
12
12
  plum-dispatch
13
13
  toolslm
@@ -22,7 +22,7 @@ Documentation = "https://fastcore.fast.ai/"
22
22
  fastcore = "fastcore._modidx:d"
23
23
 
24
24
  [project.optional-dependencies]
25
- dev = ['numpy', 'nbdev>=0.2.39', 'matplotlib', 'pillow', 'torch', 'pandas', 'nbclassic', 'pysymbol_llm', 'llms-txt', 'plum-dispatch', 'toolslm']
25
+ dev = ['numpy', 'nbdev>=0.2.39', 'matplotlib', 'pillow', 'torch', 'pandas', 'nbclassic', 'pysymbol_llm>=0.0.6', 'llms-txt', 'plum-dispatch', 'toolslm']
26
26
 
27
27
 
28
28
  [project.scripts]
@@ -1 +0,0 @@
1
- __version__ = "2.0.1"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes