When starting from scratch I would go with the first option. Cleaner code, easier to write and debug, and if the coefficient is already a Python object then the overhead is already bounded by a factor of 2.
If that is not fast enough then I would implement the polynomials as C++ templates and specialize to PyObject coefficients as needed. I would use std::map<exponent, coefficient> (that is, a binary tree) instead of std::list<std::pair<exponent, coefficient>> as underlying data structure though. Even if you don't want/need associative containers, why linked lists? Do you ever insert in the middle? Presumably polynomials are immutable => arrays or std::vector Though given that your implementation already exists and (presumably) works and is well-debugged I wouldn't change it now. Finish it, and if you run into any performance bottleneck you can explore other options. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.