Python Segment Tree Cpp Performance Brakes