You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Examples of DefineSlot and RedefineSlot for python #20839
Explain what you would like to see improved and how.
I am having again problems with multithreading in python because I seem to be using Define and Redefine, which are not thread safe. There seem to be thread safe versions of these methods called DefineSlot and RedefineSlot. However I am struggling to make it work and I cannot find any example of their usage for python.
There seem to be thread safe versions of these methods called DefineSlot and RedefineSlot
DefineSlot and RedefineSlot seem unfortunately not yet supported in Python, but luckily they are just a shortcut for Define, so you can get the same functionality in the meantime using the full expression. For example a thread-safe multi-core Gaussian random number generator:
What DefineSlot would do, if it worked with python, would be just that you would have it more compact (no need to spell the first variable rdfslot), so is just a shortcut, nothing more fancy. Side note: You still need to pass though more variables if you have extra arguments in your functor, after rdfslot.
Hi @ferdymercury, I went through this issue and the forum blog you shared. I want to work on a PR for this and wanted to check with you first if I should add documentation / Python examples for DefineSlot and RedefineSlot as part of the PR, or is there anything specific you would like me to focus on?
Thanks
Hi @ferdymercury,
I've been looking into this issue and the existing workaround using rdfslot_ with Define. I understand that DefineSlot may not be supported in Python yet.
Would it be useful if I contribute a clear Python example and documentation demonstrating the thread-safe pattern using rdfslot_, as a practical alternative to DefineSlot for thread-safe column definitions?
I can start with that, and also explore whether partial support for string-based expressions is feasible - but happy to follow your guidance on what would be most useful.
Activity
ferdymercury commentedon Jan 14, 2026
A (kind of) similar request: https://root-forum.cern.ch/t/random-number-generation-with-rdataframe/64583/3?u=ferhue
and https://root-forum.cern.ch/t/is-there-an-example-of-defineslot-with-rdataframe/34226
It seems (Re)DefineSlot does not work yet with Python
ferdymercury commentedon Jan 15, 2026
DefineSlot and RedefineSlot seem unfortunately not yet supported in Python, but luckily they are just a shortcut for Define, so you can get the same functionality in the meantime using the full expression. For example a thread-safe multi-core Gaussian random number generator:
What DefineSlot would do, if it worked with python, would be just that you would have it more compact (no need to spell the first variable rdfslot), so is just a shortcut, nothing more fancy. Side note: You still need to pass though more variables if you have extra arguments in your functor, after rdfslot.
rdf_x = rdf.DefineSlot("x", "myfunctor")Same with RedefineSlot vs Redefine
jainoshika commentedon Jan 19, 2026
Hi @ferdymercury, I went through this issue and the forum blog you shared. I want to work on a PR for this and wanted to check with you first if I should add documentation / Python examples for
DefineSlotandRedefineSlotas part of the PR, or is there anything specific you would like me to focus on?Thanks
003-kalki commentedon Jan 24, 2026
Hi @ferdymercury,
I’d like to work on this issue. Could you please assign it to me if no one else is currently working on it?
gayatripadalia commentedon Apr 4, 2026
Hi @ferdymercury,
I've been looking into this issue and the existing workaround using rdfslot_ with Define. I understand that DefineSlot may not be supported in Python yet.
Would it be useful if I contribute a clear Python example and documentation demonstrating the thread-safe pattern using rdfslot_, as a practical alternative to DefineSlot for thread-safe column definitions?
I can start with that, and also explore whether partial support for string-based expressions is feasible - but happy to follow your guidance on what would be most useful.