Подскажите как оптимизировать такой код чтоб ускорить его выполнение
"""
Embedded Python Blocks:
Each time this file is saved, GRC will instantiate the first class it finds
to get ports and parameters of your block. The arguments to __init__ will
be the parameters. All of them are required to have default values!
"""
import numpy as np
from gnuradio import gr
import threading
class blk(gr.sync_block): # other base classes are basic_block, decim_block, interp_block
"""Embedded Python Block example - a simple multiply const"""
def __init__(self, example_param=1.0): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.sync_block.__init__(
self,
name='Embedded Python Block', # will show up in GRC
in_sig=[],
out_sig=[np.complex64]a
)
self.arr= np.loadtxt('txt.dat')
print (self.arr)
self.maszero = np.zeros(1024,dtype=float)
for i in self.arr:
self.maszero[i]=10.0
self.s=np.fft.ifft(self.maszero).reshape(1024,)
#np.savetxt('txt1.dat',self.s)
np.set_printoptions(threshold=np.nan)
print (self.s.shape)
#for i in self.s:
#np.savetxt('txt1.dat', i)
# if an attribute with the same name as a parameter is found,
# a callback is registered (properties work, too).
self.example_param = example_param
def work(self, input_items, output_items):
out= output_items[0]
for i in np.arange(self.s.size):
out[i]=self.s[i]
return len(output_items[0])