bare-script 4.2.7__tar.gz → 4.2.8__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 (44) hide show
  1. {bare_script-4.2.7/src/bare_script.egg-info → bare_script-4.2.8}/PKG-INFO +1 -1
  2. {bare_script-4.2.7 → bare_script-4.2.8}/setup.cfg +1 -1
  3. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/library.py +14 -0
  4. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/runtime.py +104 -1
  5. {bare_script-4.2.7 → bare_script-4.2.8/src/bare_script.egg-info}/PKG-INFO +1 -1
  6. {bare_script-4.2.7 → bare_script-4.2.8}/LICENSE +0 -0
  7. {bare_script-4.2.7 → bare_script-4.2.8}/README.md +0 -0
  8. {bare_script-4.2.7 → bare_script-4.2.8}/pyproject.toml +0 -0
  9. {bare_script-4.2.7 → bare_script-4.2.8}/setup.py +0 -0
  10. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/__init__.py +0 -0
  11. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/__main__.py +0 -0
  12. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/bare.py +0 -0
  13. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/__init__.py +0 -0
  14. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/args.bare +0 -0
  15. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/baredoc.bare +0 -0
  16. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/baredocCLI.bare +0 -0
  17. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/data.bare +0 -0
  18. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/dataLineChart.bare +0 -0
  19. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/dataTable.bare +0 -0
  20. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/dataUtil.bare +0 -0
  21. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/diff.bare +0 -0
  22. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/draw.bare +0 -0
  23. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/elementModel.bare +0 -0
  24. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/forms.bare +0 -0
  25. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/markdown.bare +0 -0
  26. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/markdownElements.bare +0 -0
  27. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/markdownHighlight.bare +0 -0
  28. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/markdownParser.bare +0 -0
  29. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/markdownUp.bare +0 -0
  30. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/pager.bare +0 -0
  31. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/qrcode.bare +0 -0
  32. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/schemaDoc.bare +0 -0
  33. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/unittest.bare +0 -0
  34. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/include/unittestMock.bare +0 -0
  35. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/model.py +0 -0
  36. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/options.py +0 -0
  37. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/parser.py +0 -0
  38. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/runtime_c.c +0 -0
  39. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script/value.py +0 -0
  40. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script.egg-info/SOURCES.txt +0 -0
  41. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script.egg-info/dependency_links.txt +0 -0
  42. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script.egg-info/entry_points.txt +0 -0
  43. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script.egg-info/requires.txt +0 -0
  44. {bare_script-4.2.7 → bare_script-4.2.8}/src/bare_script.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bare-script
3
- Version: 4.2.7
3
+ Version: 4.2.8
4
4
  Summary: bare-script
5
5
  Home-page: https://github.com/craigahobbs/bare-script
6
6
  Author: Craig A. Hobbs
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = bare-script
3
- version = 4.2.7
3
+ version = 4.2.8
4
4
  url = https://github.com/craigahobbs/bare-script
5
5
  author = Craig A. Hobbs
6
6
  author_email = craigahobbs@gmail.com
@@ -2208,3 +2208,17 @@ EXPRESSION_FUNCTIONS = dict(
2208
2208
  (expr_fn_name, SCRIPT_FUNCTIONS[script_fn_name])
2209
2209
  for expr_fn_name, script_fn_name in EXPRESSION_FUNCTION_MAP.items()
2210
2210
  )
2211
+
2212
+
2213
+ # Library functions with an inline "intrinsic" fast path in the runtime call dispatch. Membership is by
2214
+ # function-object identity, so any override (a user function, an options global, or an unittestMock
2215
+ # systemGlobalSet) is a different object that misses the set and takes the normal call path. Kept small
2216
+ # on purpose: these hot, validation-heavy accessors measured as ~all of the include-test speedup.
2217
+ # Defined here, next to SCRIPT_FUNCTIONS, mirroring the JavaScript implementation.
2218
+ INTRINSICS = frozenset((
2219
+ SCRIPT_FUNCTIONS['arrayGet'],
2220
+ SCRIPT_FUNCTIONS['arrayPush'],
2221
+ SCRIPT_FUNCTIONS['arraySet'],
2222
+ SCRIPT_FUNCTIONS['objectGet'],
2223
+ SCRIPT_FUNCTIONS['objectSet'],
2224
+ ))
@@ -8,7 +8,7 @@ The BareScript runtime
8
8
  import datetime
9
9
  import functools
10
10
 
11
- from .library import EXPRESSION_FUNCTIONS, SCRIPT_FUNCTIONS
11
+ from .library import EXPRESSION_FUNCTIONS, INTRINSICS, SCRIPT_FUNCTIONS
12
12
  from .model import lint_script
13
13
  from .options import url_file_relative
14
14
  from .parser import parse_script
@@ -315,6 +315,109 @@ def evaluate_expression(expr, options=None, locals_=None, builtins=True, script=
315
315
  if func_value is not None:
316
316
  # Call the function
317
317
  try:
318
+ # Intrinsic fast path: run the body inline, skipping value_args_validate and the
319
+ # call frame. Bad arguments raise ValueArgsError, handled by the except below exactly
320
+ # as the normal call would; a call reaching one of these under a different name (an
321
+ # alias) matches no branch and falls through to the normal call.
322
+ if func_value in INTRINSICS:
323
+ func_args_length = len(func_args)
324
+ if func_name == 'arrayGet':
325
+ if func_args_length < 1:
326
+ raise ValueArgsError('array', None)
327
+ array_value = func_args[0]
328
+ array_type = type(array_value)
329
+ if array_type is not list:
330
+ raise ValueArgsError('array', array_value)
331
+ if func_args_length < 2:
332
+ raise ValueArgsError('index', None)
333
+ index_value = func_args[1]
334
+ index_type = type(index_value)
335
+ if index_type is float:
336
+ if index_value < 0 or not index_value.is_integer():
337
+ raise ValueArgsError('index', index_value)
338
+ index_value = int(index_value)
339
+ elif index_type is int:
340
+ if index_value < 0:
341
+ raise ValueArgsError('index', index_value)
342
+ else:
343
+ raise ValueArgsError('index', index_value)
344
+ if func_args_length > 2:
345
+ raise ValueArgsError(None, func_args_length)
346
+ if index_value >= len(array_value):
347
+ raise ValueArgsError('index', index_value)
348
+ return array_value[index_value]
349
+ if func_name == 'arrayPush':
350
+ if func_args_length < 1:
351
+ raise ValueArgsError('array', None)
352
+ array_value = func_args[0]
353
+ array_type = type(array_value)
354
+ if array_type is not list:
355
+ raise ValueArgsError('array', array_value)
356
+ array_value.extend(func_args[1:])
357
+ return array_value
358
+ if func_name == 'arraySet':
359
+ if func_args_length < 1:
360
+ raise ValueArgsError('array', None)
361
+ array_value = func_args[0]
362
+ array_type = type(array_value)
363
+ if array_type is not list:
364
+ raise ValueArgsError('array', array_value)
365
+ if func_args_length < 2:
366
+ raise ValueArgsError('index', None)
367
+ index_value = func_args[1]
368
+ index_type = type(index_value)
369
+ if index_type is float:
370
+ if index_value < 0 or not index_value.is_integer():
371
+ raise ValueArgsError('index', index_value)
372
+ index_value = int(index_value)
373
+ elif index_type is int:
374
+ if index_value < 0:
375
+ raise ValueArgsError('index', index_value)
376
+ else:
377
+ raise ValueArgsError('index', index_value)
378
+ if func_args_length > 3:
379
+ raise ValueArgsError(None, func_args_length)
380
+ if index_value >= len(array_value):
381
+ raise ValueArgsError('index', index_value)
382
+ set_value = func_args[2] if func_args_length >= 3 else None
383
+ array_value[index_value] = set_value
384
+ return set_value
385
+ if func_name == 'objectGet':
386
+ default_value = func_args[2] if func_args_length >= 3 else None
387
+ if func_args_length < 1:
388
+ raise ValueArgsError('object', None, default_value)
389
+ object_value = func_args[0]
390
+ object_type = type(object_value)
391
+ if object_type is not dict:
392
+ raise ValueArgsError('object', object_value, default_value)
393
+ if func_args_length < 2:
394
+ raise ValueArgsError('key', None, default_value)
395
+ key_value = func_args[1]
396
+ key_type = type(key_value)
397
+ if key_type is not str:
398
+ raise ValueArgsError('key', key_value, default_value)
399
+ if func_args_length > 3:
400
+ raise ValueArgsError(None, func_args_length, default_value)
401
+ return object_value.get(key_value, default_value)
402
+ if func_name == 'objectSet':
403
+ if func_args_length < 1:
404
+ raise ValueArgsError('object', None)
405
+ object_value = func_args[0]
406
+ object_type = type(object_value)
407
+ if object_type is not dict:
408
+ raise ValueArgsError('object', object_value)
409
+ if func_args_length < 2:
410
+ raise ValueArgsError('key', None)
411
+ key_value = func_args[1]
412
+ key_type = type(key_value)
413
+ if key_type is not str:
414
+ raise ValueArgsError('key', key_value)
415
+ if func_args_length > 3:
416
+ raise ValueArgsError(None, func_args_length)
417
+ set_value = func_args[2] if func_args_length >= 3 else None
418
+ object_value[key_value] = set_value
419
+ return set_value
420
+
318
421
  return func_value(func_args, options)
319
422
  except BareScriptRuntimeError:
320
423
  raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bare-script
3
- Version: 4.2.7
3
+ Version: 4.2.8
4
4
  Summary: bare-script
5
5
  Home-page: https://github.com/craigahobbs/bare-script
6
6
  Author: Craig A. Hobbs
File without changes
File without changes
File without changes
File without changes