From 1f5e2963ef69d1c7241972958b2b03611afca050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Mon, 1 Jul 2013 16:32:00 +0200 Subject: [PATCH] avoid min/max function calls per sample --- pysstv/sstv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pysstv/sstv.py b/pysstv/sstv.py index cc34358..ecd5cca 100644 --- a/pysstv/sstv.py +++ b/pysstv/sstv.py @@ -61,7 +61,8 @@ class SSTV(object): for value in self.gen_values(): sample = int(round(value * amp + alias * (random() - 0.5))) for chan in chans: - yield max(min(highest, sample), lowest) + yield (lowest if sample <= lowest else + sample if sample <= highest else highest) def gen_values(self): """generates samples between -1 and +1 from gen_freq_bits()