Skip to content

Commit 2522a06

Browse files
authored
Add --heap-size-hint parameter (#547)
* 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>
1 parent e6791c5 commit 2522a06

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

docs/src/juliacall.md

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ be configured in two ways:
124124
| `-X juliacall-threads=<N\|auto>` | `PYTHON_JULIACALL_THREADS=<N\|auto>` | Launch N threads. |
125125
| `-X juliacall-warn-overwrite=<yes\|no>` | `PYTHON_JULIACALL_WARN_OVERWRITE=<yes\|no>` | Enable or disable method overwrite warnings. |
126126
| `-X juliacall-autoload-ipython-extension=<yes\|no>` | `PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=<yes\|no>` | Enable or disable IPython extension autoloading. |
127+
| `-X juliacall-heap-size-hint=<N>` | `PYTHON_JULIACALL_HEAP_SIZE_HINT=<N>` | Hint for initial heap size in bytes. |
127128

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

docs/src/releasenotes.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Release Notes
22

3+
## Unreleased
4+
* Added `PYTHON_JULIACALL_HEAP_SIZE_HINT` option to configure initial Julia heap size.
5+
36
## 0.9.24 (2025-01-22)
47
* Bug fixes.
58

pysrc/juliacall/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def int_option(name, *, accept_auto=False, **kw):
109109
except ValueError:
110110
raise ValueError(f'{s}: expecting an int'+(' or auto' if accept_auto else ""))
111111

112-
def args_from_config():
113-
argv = [CONFIG['exepath']]
114-
for opt, val in CONFIG.items():
112+
def args_from_config(config):
113+
argv = [config['exepath']]
114+
for opt, val in config.items():
115115
if opt.startswith('opt_'):
116116
if val is None:
117117
if opt == 'opt_handle_signals':
@@ -146,6 +146,7 @@ def args_from_config():
146146
CONFIG['opt_warn_overwrite'] = choice('warn_overwrite', ['yes', 'no'])[0]
147147
CONFIG['opt_handle_signals'] = choice('handle_signals', ['yes', 'no'])[0]
148148
CONFIG['opt_startup_file'] = choice('startup_file', ['yes', 'no'])[0]
149+
CONFIG['opt_heap_size_hint'] = option('heap_size_hint')[0]
149150

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

183184
# parse options
184-
argc, argv = args_from_config()
185+
argc, argv = args_from_config(CONFIG)
185186
jl_parse_opts = lib.jl_parse_opts
186187
jl_parse_opts.argtypes = [c.c_void_p, c.c_void_p]
187188
jl_parse_opts.restype = None

0 commit comments

Comments
 (0)