It seems to be spending a lot of time in cython code, so "%crun" might give the best idea. This is part of the profile obtained by running the "copy" command 20 times:
0 0.0% 1.3% 2575 98.2% __pyx_pw_4sage_6matrix_21matrix_integer_sparse_21Matrix_integer_sparse_5__init__ 27 1.0% 2.4% 2271 86.6% __pyx_f_4sage_7modules_21vector_integer_sparse_mpz_vector_set_entry 0 0.0% 2.4% 1719 65.6% PyRun_FileExFlags 24 0.9% 3.3% 1290 49.2% __pyx_f_4sage_7modules_21vector_integer_sparse_allocate_mpz_vector 213 8.1% 11.4% 1201 45.8% sig_malloc (inline) 0 0.0% 11.4% 1193 45.5% PyRun_SimpleFileExFlags 27 1.0% 12.4% 957 36.5% __gmpz_init 38 1.4% 13.9% 930 35.5% __pyx_f_4sage_3ext_6memory_sage_sig_malloc 316 12.1% 25.9% 828 31.6% __GI___libc_malloc 163 6.2% 32.2% 751 28.7% sig_free (inline) 5 0.2% 32.4% 733 28.0% __pyx_f_4sage_3ext_6memory_sage_sig_free 0 0.0% 32.4% 705 26.9% Py_Main 323 12.3% 44.7% 512 19.5% _int_malloc 336 12.8% 57.5% 340 13.0% _int_free 334 12.7% 70.2% 334 12.7% sig_unblock (inline) There's no obvious culprit to my eye. It looks like a lot of time is spent in memory allocation and in setting of entries. Using a boolean matrix could be much more efficient. On Saturday, August 24, 2019 at 3:47:25 AM UTC-7, Frédéric Chapoton wrote: > > Hello, > > With sage 8.9.b7 under py3, I get > > sage: P = posets.TamariLattice(8) > sage: H = P._hasse_diagram > sage: L = H.lequal_matrix() > sage: %time copy(L) > CPU times: user 2.71 s, sys: 4.01 ms, total: 2.71 s > Wall time: 2.71 s > 1430 x 1430 sparse matrix over Integer Ring (use the '.str()' method to > see the entries) > > And this seems to me to be a bit too much. But maybe I am wrong ? This > comes from here: > > sage: ms = L.parent() > sage: ec = ms.element_class > sage: d = L.dict() > sage: %timeit ec(ms, entries=d, coerce=False, copy=False) > 1 loop, best of 5: 2.63 s per loop > > Any idea on what is happening ? on how to improve the situation ? > > cheers, > Frédéric > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/9bb95b07-3aeb-4a12-87a7-0953e7f23d2c%40googlegroups.com.