From 6233e1c2102559680e6f7c934a430db738148aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 28 Jan 2020 21:28:07 +0200 Subject: [PATCH] Avoid tmgen multiplicities (->slowdown) in ScatteringSystem constructor Former-commit-id: d4d20d3f019dee1765681d4b2f2fce95ea49fb37 --- qpms/qpms_c.pyx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index e421e31..98c93bf 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -385,7 +385,8 @@ cdef class ScatteringSystem: for p in particles: # find and enumerate unique t-matrix generators if p.p.op.typ != QPMS_TMATRIX_OPERATION_NOOP: raise NotImplementedError("currently, only no-op T-matrix operations are allowed in ScatteringSystem constructor") - tmg_key = id(p.f) + #tmg_key = id(p.f) # This causes a different generator for each particle -> SUPER SLOW + tmg_key = (id(p.f.generator), id(p.f.spec)) if tmg_key not in tmgindices: tmgindices[tmg_key] = tmg_count tmgobjs.append(p.f) # Save the references on BaseSpecs and TMatrixGenerators (via TMatrixFunctions) @@ -417,7 +418,7 @@ cdef class ScatteringSystem: orig.tm[tmi].op = qpms_tmatrix_operation_noop # TODO adjust when notrivial operations allowed for pi in range(p_count): p = particles[pi] - tmg_key = id(p.f) + tmg_key = (id(p.f.generator), id(p.f.spec)) tm_derived_key = (tmg_key, None) # TODO unique representation of p.p.op instead of None orig.p[pi].pos = p.cval().pos orig.p[pi].tmatrix_id = tmindices[tm_derived_key]