ROOT Version: 6.18/04
Platform: CentOS 7
Compiler: GCC 9
I’m seeing that the Python bindings of std::set
are different depending on the compiler version and how I import the std
namespace. There may be other differences, but the one I bumped in to was std::set
iteration being missing on GCC 9.
I have this test script that creates an std::set<int>
, fills it, asserts it is not empty, converts it to a Python list
, and then asserts the list
is not empty:
import sys
method = sys.argv[-1].lower()
if sys.argv[-1] == 'root':
import ROOT
std = ROOT.std
elif sys.argv[-1] == 'cppyy':
import cppyy
std = cppyy.gbl.std
else:
print('Unknown method')
sys.exit(1)
s = std.set(int)()
nentries = 5
for i in range(nentries):
s.insert(i)
assert s.size() == nentries, s
l = list(s)
assert len(l) == nentries, l
My environment is an LCG view, version 96b (ROOT 6.18/04). With platform x86_64-centos7-gcc8-opt
:
$ source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_96b x86_64-centos7-gcc8-opt
$ python set_test.py root
$ python set_test.py cppyy
The issue is that if I run from a GCC9 view, the cppyy
method fails. With platform x86_64-centos7-gcc9-opt
:
$ source /cvmfs/sft.cern.ch/lcg/views/setupViews.sh LCG_96b x86_64-centos7-gcc9-opt
$ python set_test.py root
$ python set_test.py cppyy
Traceback (most recent call last):
File "set_test.py", line 20, in <module>
assert len(l) == nentries, l
AssertionError: []
I do not see the problem on x86_64-centos7-gcc9-dbg
, x86_64-centos7-gcc62-opt
, nor x86_64-centos7-clang8-opt