Slow Point() object creation

29 views
Skip to first unread message

Amit Saha

unread,
Oct 30, 2014, 6:39:37 AM10/30/14
to sy...@googlegroups.com
Hi all,

Just noticed that creating even 1000 point objects is quite slow:

from sympy import Point
@profile
def create_points():
for i in range(1000):
Point(i, i)
i**2

create_points()

A random profiling run using https://github.com/rkern/line_profiler is here at:
https://gist.githubusercontent.com/amitsaha/bdde2b959658dda81536/raw/acf98e57aa5c3afbef497768fb777f5de2a5048f/gistfile1.txt

On an average this code takes 0.3 s. is there any way that this can be improved?

Thanks,
Amit.

Aaron Meurer

unread,
Oct 30, 2014, 11:38:05 AM10/30/14
to sy...@googlegroups.com
Your line profile isn't very helpful because all it tells you is that
the Point creation is slow, which is what you already knew. I would
try running your same code with
https://github.com/joerick/pyinstrument, or put the line profile
decorator on the geometry code.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CANODV3ksscGCmrsLE8c2dOf70Qu3X7WhuzCk1rZBZjdGD8aYJw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

Manoj Kumar

unread,
Oct 30, 2014, 6:28:58 PM10/30/14
to sy...@googlegroups.com
Hi Amit,

Just pitching in. There are sometimes disparities while benching using line_profiler (which I just noticed today).

I have a gist that takes 15s using the profiler and just 3s if I do a conventional timing using time() before and after the function.
I'm not sure if it is due to some overhead of the profiler, but you might just want to do a manual timing using time() to see if it matches, before concluding anything.

HTH.
Reply all
Reply to author
Forward
0 new messages