Skip to content

Batch particle properties update#5124

Merged
kodiakhq[bot] merged 1 commit intoespressomd:pythonfrom
NiklasMueller2001:parallel_particle_handle_params_update
Jul 29, 2025
Merged

Batch particle properties update#5124
kodiakhq[bot] merged 1 commit intoespressomd:pythonfrom
NiklasMueller2001:parallel_particle_handle_params_update

Conversation

@NiklasMueller2001
Copy link
Contributor

@NiklasMueller2001 NiklasMueller2001 commented Jul 24, 2025

Until now the update() method of the ParticleHandle class just sequentially set its parameters to new values, making one expensive update call for each new parameter. Now a batch update is performed.

@NiklasMueller2001 NiklasMueller2001 changed the title first draft Parallel parameter update for ParticleHandle Jul 25, 2025
@NiklasMueller2001 NiklasMueller2001 force-pushed the parallel_particle_handle_params_update branch from 4dcba77 to 986ee23 Compare July 29, 2025 09:28
@NiklasMueller2001 NiklasMueller2001 marked this pull request as ready for review July 29, 2025 14:51
@jngrad
Copy link
Member

jngrad commented Jul 29, 2025

Overall looks good to me. I'm currently working on this PR to deduplicate some of the common code.

Is there a particular reason to prefer the current syntax

p.update({"bonds": new_bonds, "pos": [1, 2, 3]})

over the following syntax?

p.update(bonds=new_bonds, pos=[1, 2, 3])

The latter is closer to the syntax of system.part.add(), and wouldn't require additional_properties to store overridden values. The function would take **new_properties as argument, so it would be safe to override a value without affecting the parent scope. I had to look up PEP 584 to double-check the pipe operator uses the last occurrence of a key/value pair in the return value (nothing against it, the old union syntax with expansions is also cryptic in my opinion, but removing unions makes the code easier for newcomers).

@jngrad
Copy link
Member

jngrad commented Jul 29, 2025

I see: the system.part.update() takes a dict as argument, so we mimic that in the particle class.

@jngrad jngrad force-pushed the parallel_particle_handle_params_update branch from 986ee23 to 69866d8 Compare July 29, 2025 17:14
@jngrad jngrad changed the title Parallel parameter update for ParticleHandle Batch particle properties update Jul 29, 2025
Co-authored-by: Jean-Noël Grad <jgrad@icp.uni-stuttgart.de>
@jngrad jngrad force-pushed the parallel_particle_handle_params_update branch from 69866d8 to e1b0c7e Compare July 29, 2025 17:58
Copy link
Member

@jngrad jngrad left a comment

Choose a reason for hiding this comment

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

Thanks!

@jngrad jngrad added automerge Merge with kodiak Performance labels Jul 29, 2025
@jngrad jngrad added this to the ESPResSo 5.0 milestone Jul 29, 2025
@kodiakhq kodiakhq bot merged commit 7e8da2b into espressomd:python Jul 29, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Merge with kodiak Performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants