After playing around with it a bit longer, it's clear that I misunderstood.
The issue was not with `cmd.alter` nor with `cmd.show_as`, but with
`cmd.sync`.

I was calling many times a smaller function that contained `cmd.sync()`,
which resulted - it seems - in all these calls piling up.

Still, I don't know if it's intended behaviour for `sync` to be so much
slower if it's called as a pymol function. Attached you will find a minimal
working example to show the difference.


Il giorno lun 16 dic 2019 alle ore 17:52 Thomas Holder <
thomas.hol...@schrodinger.com> ha scritto:

> OK thanks. I haven't seen such performance differences before and couldn't
> reproduce it so far. Could you share your script (and data files if
> possible) with me?
>
> Thanks,
>   Thomas
>
>
> > On Dec 16, 2019, at 5:42 PM, Lorenzo Gaifas <bris...@gmail.com> wrote:
> >
> > Yes, it does. Both cases are with the GUI and ewual graphical
> representation.
> >
> > On Mon, Dec 16, 2019, 17:37 Thomas Holder <thomas.hol...@schrodinger.com>
> wrote:
> > Hi Lorenzo,
> >
> > When you say "run from a python script", is that with the graphical GUI?
> That "instant update", does that include instant update of visual
> representations?
> >
> > Thanks,
> >   Thomas
> >
> >
> > > On Dec 13, 2019, at 12:55 PM, Lorenzo Gaifas <bris...@gmail.com>
> wrote:
> > >
> > > Dear Pymol users,
> > >
> > > I just discovered something I did not expect: the same python function
> can have extremely different performance when called as a python function
> or using the pymol api.
> > >
> > > To be more specific: I have a function func that (among other things)
> uses cmd.alter several times over a big system to change the properties and
> representation.
> > >
> > > If I run it calling func() from a python script, its effects are
> almost instant. If I call it with cmd.do('func') (or directly from within
> pymol with func), it’s extremely slow (up to 10 seconds) and Pymol freezes
> completely during this time.
> > >
> > > I expected this to be due to an overhead of the api itself, but when I
> do the same thing with a simpler function, I see no noticeable difference.
> > >
> > > Why exactly is this happening? And more importantly, how can I get the
> performance of func even when I call it from within pymol?
> > >
> > > Thank you,
> > > Lorenzo
> > >
> > > _______________________________________________
> > > PyMOL-users mailing list
> > > Archives:
> http://www.mail-archive.com/pymol-users@lists.sourceforge.net
> > > Unsubscribe:
> https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe
> >
> > --
> > Thomas Holder
> > PyMOL Principal Developer
> > Schrödinger, Inc.
> >
>
> --
> Thomas Holder
> PyMOL Principal Developer
> Schrödinger, Inc.
>
>
#!/usr/bin/env python3

import pymol
from pymol import cmd
import __main__

__main__.pymol_argv = ['pymol']
pymol.finish_launching()


def heavy():
    for _ in range(100):
        print('things are happening')
        cmd.sync()


if __name__ == '__main__':
    cmd.extend('heavy', heavy)

    # this function takes instants
    #heavy()

    # this one takes quite long between iterations.
    # the same happens when calling 'heavy' from within pymol
    #cmd.do('heavy')
_______________________________________________
PyMOL-users mailing list
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
Unsubscribe: 
https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe

Reply via email to