jump to navigation

When python’s dynamism can’t catch to C++ polymorphism November 1, 2012

Posted by bossudenotredame in Computer Algebra, Programming.
trackback

When you start programming with python, you start pooh-poohing every ritual you had to go through in c++ world. I mean who on the earth in the age of youtube generation wastes its time and break its head dealing with memory allocation, allocating memory is like washing your clothes by hand, when there is a washing machine at arm reach.

However, while writing a code today I missed something I was taking in c++ for granted: function polymorphism is very essential when you inherit objects.

Here, I’m inheriting AutomophismGroup from PermutationGroup in sage. PermutationGroup can generate subgroup using different data, like generators or a gap group. However, AutomorphismGroup need a very specific data (the algebraic equations of the automorphism) to generate a subgroup of AutomorphismGroup kind. On the other hand, the less sophisticated perm subgroups are still legit subgroup of AutomorphismGroup, mathematically speaking.

Now if sage was in c++, this was a none-issue. c++ check how you want to generate the subgroup: with sophisticated data? then it calls the child subgroup function, with primitive data then calls the subgroup function of the parent.

However, sage is in python, and I have to deal with this ugly error cause I have no organic way of preferring parent method over the child.

Morale: Dynamism with all simplicity it has to offer, can’t claim all what typed polymorphism can do.

Comments»

No comments yet — be the first.

Leave a comment