Repository navigation
Conversation
…y-depth values) - The value conversion walks with an explicit stack instead of recursing, so a value nested any depth crosses both ways (the parser's max_depth default is going to 100000). A list or dict shared within a value converts to one object, both ways: sharing survives the trip, a shared structure converts in time proportional to its size, and a DSL list that holds itself becomes a Python list that holds itself. A Python value that holds itself still raises ValueError. - The deep-data jobs (#658, #665): data_job, the make_*_job factories, run_to_completion, run_data_job (a Python callable as `then`), call_function, is_compound, count_data_nodes, kDataNodeBytes. A job is handed to Python owned (std::unique_ptr); `who` is kept for good, as C++ holds the pointer. - The heap (#667): heap_options and its tree settings, measure_heap_share, make_heap_share_job, heap_remeasure_bytes, and the per-thread cycle collector; the heap fields on process and process_info, evaluator_state.heap_measured, stackless_evaluator.global_env(), eval_alloc_note. - stdlib_registry: standard() (a copy), shared_scope(), register_function (a Python callable or a pycvc.value native), list_*, import_module, lookup_qualified (KeyError where C++ returns nullptr). - SWIG_STD_MOVE moves on MSVC too (it reports __cplusplus 199711L without /Zc:__cplusplus), so a unique_ptr argument can be passed. test_pycvc_state_exec_data.py covers the new calls, and test_pycvc_state_exec.py the any-depth, sharing conversion. The parity doc and README are updated.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #675. The base is
feat/pycvc-state-exec-parity-3; the diff here is part 4 only.Part 4 of bringing pycvc's state_exec API to the C++ surface, under the C++ names. It wraps what #658, #665 and #667 added and
stdlib_registry, and removes the value conversion's depth limit. After it,docs/PYCVC_STATE_EXEC_PARITY.md's inventory has every public item wrapped or listed as an exception with its reason.The value conversion takes any depth
PR 1's converter recursed and stopped at 1000 levels with
ValueError. Now it walks with an explicit stack, as the parser and the evaluator do. That matters because parser.max_depth's default is going to 100000; that change is the deep-data session's, agreed with it.ValueError, because only the evaluator's own containers are tracked for cycle collection.New, under the C++ names
data_job(step,result,nodes), themake_*_jobfactories,run_to_completionandrun_data_job(thenis a Python callable), pluscall_function,is_compound,count_data_nodesandkDataNodeBytes.std::unique_ptr), whichrun_data_jobtakes over.whois kept for good, because C++ holds the pointer for errors raised after the call.call_functionworks as for a C++ native: it calls a native function directly, and a lambda runs as the process's own frames. So a Python function can call DSL lambdas; the tests do it on both schedulers.heap_optionsandheap_options_from_state(limits.heap_check_steps),measure_heap_share,make_heap_share_jobandheap_remeasure_bytes;collect_cycles(withcycle_stats),cycle_collection_due,note_process_exitandtracked_objects;processandprocess_info,process.heap_measure_due()andrelease_state();evaluator_state.heap_measured(read-only),stackless_evaluator.global_env()andeval_alloc_note.stdlib_registry:standard()returns a copy, so Python can't add to the registry every environment shares.shared_scope()gives the frozen scope.register_functiontakes a Python callable or apycvc.valuenative.list_functions,list_modulesandimport_module.lookup_qualifiedraisesKeyErrorwhere C++ returns nullptr.Not wrapped, with reasons in the doc
call_request,take_call,pending_call,call_returned,own_inputs) anddetail::: for C++ job implementations.heap_after_step: the schedulers' own per-step accounting.track_captured_env/track_mutated: a value from Python is a fresh copy, so tracking it would mean nothing.eval_alloc_guard::allocated(): the guard isn't wrapped.Build note
SWIG passes by-value arguments with
SWIG_STD_MOVE, which expands tostd::moveonly when__cplusplussays C++11. MSVC reports 199711L unless built with/Zc:__cplusplus, so there the wrapper copied, and astd::unique_ptrcan't be copied.pycvc.inow defines it asstd::movefor the wrapper functions, which is what GCC and Clang already do.Tests
bindings/pycvc/test_pycvc_state_exec_data.pyhas 10 tests:run_data_joboutside an evaluator, and the job handed over;call_functionon both schedulers, and the error outside a running program;global_env();test_pycvc_state_exec.pygainstest_conversion_takes_any_depth_and_keeps_sharing.Local results (Windows MSVC 14.38 Release, SWIG 4.4.1, Python 3.11, cvcpkg prefix), on master as of #677 plus #661's squash:
pycvc.i;ruff(E, F, W) clean.Not run on this PR: pycvc_gl. Five of its scripts fail on master itself; see #675 for the control build. A separate fix is proposed.