I've done some profiling of my code and it seems that my main slowdowns are coming from multiplication and addition of free algebra elements. Is there anyway I can make it go faster? I would like to do some more complicated computations but currently my code has been running for half an hour and still hasn't produced any results. I plan on parallelizing it in a few places, but was wondering if I could do anything about this as well. I tried compiling phi_ext_sk down to c with cython and added type hints in a few places but it didn't help.
Specifically, here is what I get. 307 """ 308 phi_b_ext returns phi_b_ext(a_ij) 309 """ 310 311 32 37956 1186.1 0.2 e = self.phi_ext_sk(self.w[0], a) 312 313 416 431 1.0 0.0 for i in self.w[1:]: 314 384 229 0.6 0.0 new_e = 0 315 10152 11593 1.1 0.1 for k, v in e._FreeAlgebraElement__monomial_coefficients.iteritems(): 316 9768 14406 1.5 0.1 new_g = 1 317 58800 158459 2.7 0.7 for g, p in k: 318 49032 6465240 131.9 30.0 g1 = self.phi_ext_sk(i, g) 319 49032 7820633 159.5 36.3 new_g = new_g*g1 320 49032 47335 1.0 0.2 if p != 1: 321 print "POW!!!!" 322 9768 2818386 288.5 13.1 new_g = v*new_g 323 9768 4146233 424.5 19.3 new_e = new_e + new_g 324 384 6524 17.0 0.0 e = new_e 325 326 32 16 0.5 0.0 return e Function: phi_ext_sk at line 253 [4/681] Total time: 6.70627 s Line # Hits Time Per Hit % Time Line Contents ============================================================== 253 @profile 254 def phi_ext_sk(self, k, a): 255 """ 256 phi_ext_sk returns phi^ext_sigma_z(a_xy) 257 """ 258 259 49064 3622876 73.8 54.0 i, j = self.gdicta[a] 260 261 49064 46425 0.9 0.7 if k > 0: 262 263 49064 34162 0.7 0.5 if i == k + 1: 264 12004 8191 0.7 0.1 if j != k and j != k + 1: 265 8460 8997 1.1 0.1 return self.astar[k, j] 266 else: 267 3544 3904 1.1 0.1 return self.astar[k, k+1] 268 37060 23978 0.6 0.4 elif j == k + 1: 269 12004 8038 0.7 0.1 if i != k and i != k + 1: 270 8460 9035 1.1 0.1 return self.astar[i, k] 271 else: 272 3544 3927 1.1 0.1 return self.astar[k+1, k] 273 25056 16273 0.6 0.2 elif i == k and j != k and j != k + 1: 274 7016 685746 97.7 10.2 return -1*self.astar[k+1, j]-self.astar[k+1, k]* \ 275 7016 760791 108.4 11.3 self.astar[k, j] 276 18040 12076 0.7 0.2 elif j == k and i != k and i != k + 1: 277 7016 681617 97.2 10.2 return -1*self.astar[i, k+1]-self.astar[i, k]* \ 278 7016 759046 108.2 11.3 self.astar[k, k+1] 279 11024 9371 0.9 0.1 elif i != k and i != k+1 and j != k and j != k+1: 280 11024 11820 1.1 0.2 return self.astar[i, j] https://github.com/syamajala/KnotContactHomology/blob/master/braids.py -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/groups/opt_out.