On Sun, Sep 23, 2018 at 7:23 PM William Stein <wst...@gmail.com> wrote:
>
> On Sun, Sep 23, 2018 at 9:57 AM, Simon King <simon.k...@uni-jena.de> wrote:
> > Hi Andy,
> >
> > On 2018-09-23, Andy Howell <a...@gamubaru.com> wrote:
> >> I'd guess the word "tricks" was objectionable. What I meant was
> >> techniques like locating the source using funcName? Now that I know that
> >> exists, I can add it to my "practice". Discovering those though google
> >> searches takes time. I'd rather have a catalog of them in a known place.
> >> Sadly my memory is not getting better with age. Having one place to
> >> check speeds the process.
> >
> > Searching for the sources should actually be easy: Put ?? after the
> > object you want to study, and hit return (or shift-return in a
> > notebook). This is supposed to show you the source code of the object.
> >
> > Also, if you want to directly *edit* the source code, it is possible to do
> >     edit(object_you_are_investigating, 'vim')
> > (where the string 'vim' is supposed to be the name of your favourite editor 
> > ;-)
> > That said, I am hardly using edit(...) myself, usually I just look up
> > what file is relevant (by ??) and open it in geany.
> >
> > Of course, after altering the source code, you'd need to run "sage -b"
> > (or "sage -br") to build the changes (or build the changes and restart
> > sage).
> >
> > Note that you'll find introspection stuff in sage.misc.sageinspect, such as
> > this:
> >   sage: from sage.misc.sageinspect import sage_getfile
> >   sage: P.<x,y,z> = QQ[]
> >   sage: sage_getfile(P)
> >   
> > '/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_libsingular.pyx'
> >   sage: sage_getfile(x)
> >   
> > '/home/king/Sage/git/sage/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx'
> >
> > However, be warned: I just notice that the anser of sage_getfile(P) is
> > wrong (the source file is NOT in local/lib/..., but of course in
> > src/sage/rings/... Only the anser for sage_getfile(x) is correct.
>
> +1 to pointing this out. People have been confused about
>
>  
> '/home/king/Sage/git/sage/local/lib/python2.7/site-packages/sage/rings/polynomial/multi_polynomial_libsingular.pyx'
>
> versus
>
> '/home/king/Sage/git/sage/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx'
>
> probably thousands of times (with both sage and python in general).
> Setuptools has a "python setup.py develop" mode
> that sometimes fixes this, but we don't use it...

I have been hoping to fix that practically since Day One of working on Sage.

Some people don't like that because it causes build artifacts to get
mixed in with your source code.  For myself, I have zero problem with
that.  .gitignore takes care of it for the most part, and when it
comes to browsing/editing source I'm mostly doing that from vim, and
most plugins I use like NerdTree and Ctrl-P can be configured to hide
those files as well, so I don't see the problem.

One idea would be to make it a matter of preference.  I should be able
to use `setup.py develop` if I choose to, but it should work either
way I suppose.
One reason setup.py develop is perhaps less useful for Sage is the
prevalence of compiled modules.  But even there, one can configure
workarounds.  For example, in the past on other projects I've done
things like have a custom .pth file that would rebuild my extension
modules at interpreter start-up if I was in my development virtualenv.
Obviously makes for slower startup, but it's one less step that I have
to do manually.



> > Question to all: Is there already a ticket for the wrong behaviour of
> > sage_getfile?
> >
> >>>     How to I find the code being called?
> >>>
> >>>
> >>> %prun is reasonably good for that. The foo?? is also very useful for
> >>> looking at a particular block of code.
> >
> > If the code isn't pure python, %crun might also be useful (for
> > performance analysis), although you need to install gperftools to make
> > it work.
> >
> > 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.
>
>
>
> --
> William (http://wstein.org)
>
> --
> 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.

-- 
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.

Reply via email to