Comments (4)
I also share your view @damienmarchal. It feels natural like this. When you pass an object or data as a parameter, you pass a "reference" to it. When you pass a value, you make a copy. +1 for me
from sofapython3.
Thanks @jnbrunet for the feedback.
Yesterday I made several tests to see the look and feel and made
def createScene(root):
root.addObject("MeshObjLoader", filename="mesh/cube.obj", name="loader");
a = root.addObject("PointSetTopologyContainer", position=root.loader.position.linkpath, name="topo")
b = root.addObject("PointSetTopologyContainer", position=root.loader.position.value, name="topo")
So there is an explicit version for the two cases.
And for the implicit one:
a = root.addObject("PointSetTopologyContainer", position=root.loader.position, name="topo")
We need to decide if we continue to copy values (what we are doing right now) or if we make a link (more breaking ?).
With link-by-default, the performances will be very good but users has to understand what a link and fallback to value copy-value if this cause issues in their scenes .
with copy-by-default approach the performances will be bad and user will have to op-in for the fastest (link-base) version.
from sofapython3.
Another alternative could be to first deprecate (with a warning message) the existing implicit version then replace it with an exception saying that this ambiugous and force to replace it with one of the explicit ones.
a = root.addObject("PointSetTopologyContainer", position=root.loader.position.linkpath, name="topo")
b = root.addObject("PointSetTopologyContainer", position=root.loader.position.value, name="topo")
from sofapython3.
Hey @damienmarchal
I'm curious in which cases the user would prefer a copy against a (COW anyway?) link. I have a feeling that a link would be more appropriate for most needs, hence creating less frustrations for the user, but I may be wrong.
From experience, people will naturally set the attribute to the source data directly, i.e.:
node.addObject("MechanicalObject", position=node.loader.position)
And forget about it. It is also much simpler to read. But it does come with an implicit decision made for the user.
A warning here would, I think, generate a "What the f. is that? Which one should I use? I just want this component positions..." In the user's head.
I am usually in favor of explicit against implicit, but here I think it is a good case of simplicity outweighs the cost of implicity (the cost which I think is minimal anyway...) .
My 2 cents! Whatever you choose, it will be a great improvement.
from sofapython3.
Related Issues (20)
- Memory leak in DataContainer HOT 3
- Memory leak when unloading a graph
- Memory Leak related to unload and rendering HOT 3
- isDirty returning always false with writeable access HOT 1
- Missing "*Targets.cmake"files when building SofaPython3
- Sofapython3 plugin loading HOT 1
- [SofaPython3] additional example running issue HOT 1
- CollisionGroup not updating value HOT 14
- The specified module could not be found. HOT 1
- emptyController.py HOT 2
- addLink does not work
- Cannot load SofaPython3 HOT 5
- no plugin.SofaPython3/build
- Segmentation fault with python embedded by conda on macOS
- Roadmap for the SofaPython3 plugin
- Use Quaternion and to_euler, to_maxtrix in SofaPython3 HOT 1
- Externalise Qt gui
- SimpleApi dependency HOT 2
- SofaPython3 - Installation on Windows 11 -release version 23.06 - Module not found error HOT 2
- SOFA_v23.06.00_Linux works, SOFA_v23.12.00_Linux doesn't work. No module named 'Sofa.Helper'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sofapython3.