Skip to content

Add new generic add method - #530

Open
bakpaul wants to merge 2 commits into
sofa-framework:masterfrom
bakpaul:25_08_create_new_add_method_and_avoid_serialization
Open

Add new generic add method#530
bakpaul wants to merge 2 commits into
sofa-framework:masterfrom
bakpaul:25_08_create_new_add_method_and_avoid_serialization

Conversation

@bakpaul

Copy link
Copy Markdown
Contributor

This method's goal is to reduce as much as possible thee data serialization

Comment threadbindings/Sofa/tests/Simulation/Node.py Outdated
Comment threadbindings/Sofa/tests/Simulation/Node.py Outdated
Comment threadbindings/Sofa/tests/Simulation/Node.py Outdated
}
}

py::object add( Node* self, const std::string& type, const py::kwargs& kwargs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add a second signature so we can pass real type instead of string.

py::objectadd( Node*self, py::type type, constpy::kwargs&kwargs)
{
if(issubchild(type, BaseObject)){
... }elseif(issubchild(type, Node)){
....
}
}

But this could be in a second PR.

name = py::str(kwargs["name"]);
if (sofapython3::isProtectedKeyword(name))
throw py::value_error("Cannot call addObject with name " + name + ": Protected keyword");
}

@damienmarchaldamienmarchalSep 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we consider to add a name generation mechanism (with +1) to avoid having name duplicated.
Of course this have a non linear performance hit in case of gigantic scene... but I would be in favor of having a robust normal add() and a second one considered "fast mode" for expert users.

Co-authored-by: Damien Marchal <damien.marchal@univ-lille1.fr>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@bakpaul@damienmarchal@hugtalbot