Hi Dima, On 2018-12-26, Dima Pasechnik <dimp...@gmail.com> wrote: > E.g. do not do > > G = libgap('DihedralGroup(8)') > > instead do > > G = libgap.DihedralGroup(8)
Sure, that's what I do. I also used to do gap.DihedralGroup(8), which works just as well. I just chose an example to point out that the two call methods have a different semantics. >> sage: L = gap('[1,2,3]') >> sage: L[1] >> 1 > > this is guaranteed constant headache, leading to madness or more > likely abandonment and bitrot, having in Python list-like 1-based > objects, > next to normal 0-based objects... Pythonisti fed devs to hungry serpents for > lesser degrees of non-Pythonness... Sure. I am saying that GAP did a wrong choice, and arguably it was a bad choice in gap to follow GAP's convention. libgap being 0-based is good! However, it means libgap cannot be a drop-in replacement for gap, and the change from gap to libgap will, for some time, create trouble for users. So, one cannot just remove gap all of a sudden, in particular not without a deprecation. And the same should hold for r. >> - libgap.__call__ on a string does not interprete that string but >> returns a GAP string. > > I don't understand - you get a Python wrapper to a GAP object if you > call libgap appropriately, > not a string. No. See the examples I gave. libgap('bla') gives GAP string (which of course is my abbreviation for "Python wrapper of a GAP string"). gap('bla') tries to evaluate 'bla' as a command. Similarly to the above 1- versus 0-based, I am saying that libgap arguably works better than gap (so, please don't change libgap now!). But again, it means a headache for users and thus removing gap and replacing it with libgap must not happen without a deprecation. > I'd like to have a look at this code: perhaps half, if not all, of > libgap.eval() > calls can be replaced by something more Pythonic. Currently I use it for the following purposes: 1. Creating examples in the doc strings. Reason: I simply don't know how to express the GAP command Group( [ (1,2)(3,8)(4,6)(5,7), (1,3)(2,5)(4,7)(6,8) ] ) in libgap. I tried libgap.Group( [ ((1,2),(3,8),(4,6),(5,7)), ((1,3),(2,5),(4,7),(6,8)) ] ) but it fails. 2. Testing if a construction fails, by a comparison such as if phi == libgap.eval('fail')... I would prefer "if phi == libgap.fail...", but it fails. 3. Calling GAP's `InstallValue`. I tried to do it via libgap.function_factory, but without success. 4. Pickling. GAP has, as far as I can see, very poor support for serialisation. In my application, I am dealing with permutation groups, that can be reconstructed from their string representation. So, I store this and do unpickling by libgap.eval(...). I would be happy to learn of more efficient ways of pickling a group in GAP, but for backwards compatibility (opening old pickles) I need to keep evaluating strings. Best regards, Simon -- 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 https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.