# How to use Snapshot template parameters in pyRoot

**URL:** <https://root-forum.cern.ch/t/how-to-use-snapshot-template-parameters-in-pyroot/63808>\
**Category:** ROOT\
**Created:** [June 26, 2025, 4:57pm UTC](https://root-forum.cern.ch/t/how-to-use-snapshot-template-parameters-in-pyroot/63808 "2025-06-26T16:57:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimitris\_lepipas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dimitris_lepipas/32/37300_2.png) [@dimitris\_lepipas](https://root-forum.cern.ch/u/dimitris_lepipas)\
**Post date:** [June 26, 2025, 4:57pm UTC](https://root-forum.cern.ch/t/how-to-use-snapshot-template-parameters-in-pyroot/63808/1 "2025-06-26T16:57:46Z")

</div>

* * *

_ROOT Version:_ 6.34.4  
_Platform:_ Linux  
_Compiler:_ Not Provided

* * *

Based on the answer here [RDataFrame tree conversion takes too much time and memory - #9 by eguiraud](https://root-forum.cern.ch/t/rdataframe-tree-conversion-takes-too-much-time-and-memory/40853/9)  
seems that using `Snapshot template parameters` makes Snapshot a lot faster.

Is there a way to do it in python assuming that the column types are `string` and `uint64` ?

---

<div class="post-metadata">

**Author:** ![lbreitwi](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lbreitwi/32/21330_2.png) [@lbreitwi](https://root-forum.cern.ch/u/lbreitwi)\
**Post date:** [June 30, 2025, 4:24pm UTC](https://root-forum.cern.ch/t/how-to-use-snapshot-template-parameters-in-pyroot/63808/2 "2025-06-30T16:24:22Z")

</div>

@vpadulan could you please take a look at this question?

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [July 1, 2025, 8:27am UTC](https://root-forum.cern.ch/t/how-to-use-snapshot-template-parameters-in-pyroot/63808/3 "2025-07-01T08:27:14Z")

</div>

Dear @dimitris_lepipas ,

Thank you for reaching out to the forum!

Good timing on your question! We have just finished an improvement of the capability of the RDataFrame `Snapshot` such that it won’t be necessary anymore to specify any template arguments at all. At the same time, this will also _not_ require any JIT-compiling. That practically means that you get the benefit of a simpler API (i.e. no need to care about template arguments) with a much, much faster runtime performance.

The change has just been merged to the development branch of ROOT, so it’s going to be available in the next ROOT version 6.38 scheduled for end of this year. In the meanwhile, if you have access to an LCG release via CVMFS, for example using `lxplus`, you can already see this in action. You can source the environment via e.g.

```auto
source /cvmfs/sft.cern.ch/lcg/views/dev3/latest/x86_64-el9-gcc13-opt/setup.sh

```

In the meanwhile, you might want to hang tight and use the Snapshot API without template arguments, which for now will still be slower but it’s also going to require zero code-changes for you after the update to 6.38. The template overload will be deprecated and slowly phased out.

Lastly, I still believe your question is interesting from a generic Python-C++ interoperability standpoint, so here it goes. If you have _any_ function template in C++, you can call it in Python with the `[]` syntax, for example:

```auto
import ROOT

ROOT.gInterpreter.Declare(r"""
    template <typename T>
    void foo(T val) { std::cout << val << "\n"; }
""")

ROOT.foo[float](42.42)

```

So you can use the same syntax also in the case of the template Snapshot, although as I mentioned above this template will be removed in a future version of ROOT.

Cheers,  
Vincenzo

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 15, 2025, 8:28am UTC](https://root-forum.cern.ch/t/how-to-use-snapshot-template-parameters-in-pyroot/63808/4 "2025-07-15T08:28:03Z")

</div>

Closed on July 15, 2025, 8:28am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
