From 9c4418af527866f2103180585af723448abd6660 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 18 Mar 2024 10:28:37 +0100 Subject: [PATCH] [relnotes] Mention cppyy upgrade in release notes --- README/ReleaseNotes/v632/index.md | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README/ReleaseNotes/v632/index.md b/README/ReleaseNotes/v632/index.md index 7d88a0f4fbf72..f7acf1583a7c4 100644 --- a/README/ReleaseNotes/v632/index.md +++ b/README/ReleaseNotes/v632/index.md @@ -224,6 +224,48 @@ Please use the higher-level functions `RooAbsPdf::createNLL()` and `RooAbsPdf::c ## PROOF Libraries +## PyROOT + + +### Rebase of PyROOT on the current cppyy + +PyROOT was rebased on the latest version of the [cppyy library](https://cppyy.readthedocs.io/en/latest/). +This means PyROOT benefits from many upstream improvements and fixes, for example related to the conversion of NumPy arrays to vectors, implicit conversion from nested Python tuples to nested initializer lists, and improved overload resolution. + +Related to this cppyy upgrade, there is one change in PyROOT behavior. +A static size character buffer of type `char[n]` is not converted to a Python string anymore. +The reason for this: since it was previously assumed the string was +null-terminated, there was no way to get the bytes after a `null`, even if you +wanted to. + +``` +import ROOT + +ROOT.gInterpreter.Declare(""" +struct Struct { char char_buffer[5] {}; }; // struct with char[n] +void fill_char_buffer(Struct & st) { + std::string foo{"foo"}; + std::memcpy(st.char_buffer, foo.data(), foo.size()); +} +""") + +struct = ROOT.Struct() +ROOT.fill_char_buffer(struct) +char_buffer = struct.char_buffer + +# With thew new cppyy, you get access to the lower level buffer instead of a +# Python string: +print("struct.char_buffer : ", char_buffer) + +# However, you can turn the buffer into a string very easily with as_string(): +print("struct.char_buffer.as_string(): ", char_buffer.as_string()) +``` +The output of this script with ROOT 6.32: +``` +struct.char_buffer : +struct.char_buffer.as_string(): foo +``` + ## Language Bindings