Commit 52a3bb1a authored by Kipp Cannon's avatar Kipp Cannon

gpsproperty.__get__(): reduce operation count

- for better performance in gstlal inspiral pipeline
parent d5d5587b
Pipeline #39350 failed with stages
in 3 minutes and 9 seconds
......@@ -39,6 +39,7 @@ except ImportError:
from functools32 import total_ordering
import math
import numpy
import operator
import warnings
from xml import sax
......@@ -267,20 +268,21 @@ class gpsproperty(object):
"""
def __init__(self, s_name, ns_name):
self.s_name = s_name
self.get_s = operator.attrgetter(s_name)
self.ns_name = ns_name
self.get_ns = operator.attrgetter(ns_name)
posinf = 0x7FFFFFFF, 0xFFFFFFFF
neginf = 0xFFFFFFFF, 0xFFFFFFFF
infs = posinf, neginf
def __get__(self, obj, cls = None):
s = getattr(obj, self.s_name)
ns = getattr(obj, self.ns_name)
s = self.get_s(obj)
ns = self.get_ns(obj)
if s is None and ns is None:
return None
if (s, ns) == self.posinf:
return segments.PosInfinity
if (s, ns) == self.neginf:
return segments.NegInfinity
if (s, ns) in self.infs:
return segments.PosInfinity if (s, ns) == self.posinf else segments.NegInfinity
return LIGOTimeGPS(s, ns)
def __set__(self, obj, gps):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment