Polymorphic container for C++ with optional python bindings