Skip to content

Commit

Permalink
Add --heap-size-hint parameter (#547)
Browse files Browse the repository at this point in the history
* refactor: avoid spooky action at a distance in init

* feat: add heap-size-hint

* docs: add heap-size-hint to docs and release notes

---------

Co-authored-by: Christopher Doris <github.com/cjdoris>
  • Loading branch information
MilesCranmer authored Feb 21, 2025
1 parent e6791c5 commit 2522a06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/src/juliacall.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ be configured in two ways:
| `-X juliacall-threads=<N\|auto>` | `PYTHON_JULIACALL_THREADS=<N\|auto>` | Launch N threads. |
| `-X juliacall-warn-overwrite=<yes\|no>` | `PYTHON_JULIACALL_WARN_OVERWRITE=<yes\|no>` | Enable or disable method overwrite warnings. |
| `-X juliacall-autoload-ipython-extension=<yes\|no>` | `PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=<yes\|no>` | Enable or disable IPython extension autoloading. |
| `-X juliacall-heap-size-hint=<N>` | `PYTHON_JULIACALL_HEAP_SIZE_HINT=<N>` | Hint for initial heap size in bytes. |

## [Multi-threading](@id py-multi-threading)

Expand Down
3 changes: 3 additions & 0 deletions docs/src/releasenotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Release Notes

## Unreleased
* Added `PYTHON_JULIACALL_HEAP_SIZE_HINT` option to configure initial Julia heap size.

## 0.9.24 (2025-01-22)
* Bug fixes.

Expand Down
9 changes: 5 additions & 4 deletions pysrc/juliacall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def int_option(name, *, accept_auto=False, **kw):
except ValueError:
raise ValueError(f'{s}: expecting an int'+(' or auto' if accept_auto else ""))

def args_from_config():
argv = [CONFIG['exepath']]
for opt, val in CONFIG.items():
def args_from_config(config):
argv = [config['exepath']]
for opt, val in config.items():
if opt.startswith('opt_'):
if val is None:
if opt == 'opt_handle_signals':
Expand Down Expand Up @@ -146,6 +146,7 @@ def args_from_config():
CONFIG['opt_warn_overwrite'] = choice('warn_overwrite', ['yes', 'no'])[0]
CONFIG['opt_handle_signals'] = choice('handle_signals', ['yes', 'no'])[0]
CONFIG['opt_startup_file'] = choice('startup_file', ['yes', 'no'])[0]
CONFIG['opt_heap_size_hint'] = option('heap_size_hint')[0]

# Stop if we already initialised
if CONFIG['inited']:
Expand Down Expand Up @@ -181,7 +182,7 @@ def args_from_config():
CONFIG['lib'] = lib = c.PyDLL(libpath, mode=c.RTLD_GLOBAL)

# parse options
argc, argv = args_from_config()
argc, argv = args_from_config(CONFIG)
jl_parse_opts = lib.jl_parse_opts
jl_parse_opts.argtypes = [c.c_void_p, c.c_void_p]
jl_parse_opts.restype = None
Expand Down

0 comments on commit 2522a06

Please sign in to comment.