Change in osmocom-bb[master]: trx_toolkit/fake_trx.py: avoid using TRXList.__getitem__()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

fixeria gerrit-no-reply at lists.osmocom.org
Sun Jul 12 12:54:07 UTC 2020


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/19223 )


Change subject: trx_toolkit/fake_trx.py: avoid using TRXList.__getitem__()
......................................................................

trx_toolkit/fake_trx.py: avoid using TRXList.__getitem__()

Running with cProfile shows that there are quite a lot calls:

  469896    0.254    0.000    0.254    0.000 trx_list.py:37(__getitem__)

Let's better avoid using it in performance critical parts.

Change-Id: I2bbc0a2af8218af0b9a02d8e16d4216cf602892a
---
M src/target/trx_toolkit/fake_trx.py
M src/target/trx_toolkit/trx_list.py
2 files changed, 4 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/23/19223/1

diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py
index 4a49fa3..82eb5b7 100755
--- a/src/target/trx_toolkit/fake_trx.py
+++ b/src/target/trx_toolkit/fake_trx.py
@@ -411,7 +411,7 @@
 				self.append_child_trx(addr, port, idx, name)
 
 		# Burst forwarding between transceivers
-		self.burst_fwd = BurstForwarder(self.trx_list)
+		self.burst_fwd = BurstForwarder(self.trx_list.trx_list)
 
 		log.info("Init complete")
 
@@ -444,7 +444,7 @@
 	def run(self):
 		# Compose list of to be monitored sockets
 		sock_list = []
-		for trx in self.trx_list:
+		for trx in self.trx_list.trx_list:
 			sock_list.append(trx.ctrl_if.sock)
 			sock_list.append(trx.data_if.sock)
 
@@ -454,7 +454,7 @@
 			r_event, _, _ = select.select(sock_list, [], [])
 
 			# Iterate over all transceivers
-			for trx in self.trx_list:
+			for trx in self.trx_list.trx_list:
 				# DATA interface
 				if trx.data_if.sock in r_event:
 					msg = trx.recv_data_msg()
diff --git a/src/target/trx_toolkit/trx_list.py b/src/target/trx_toolkit/trx_list.py
index 4f9eff2..3206d74 100644
--- a/src/target/trx_toolkit/trx_list.py
+++ b/src/target/trx_toolkit/trx_list.py
@@ -34,6 +34,7 @@
 	def __init__(self, trx_list = None):
 		self.trx_list = trx_list or []
 
+	# NOTE: do not use this in performance critical parts
 	def __getitem__(self, i):
 		return self.trx_list[i]
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/19223
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I2bbc0a2af8218af0b9a02d8e16d4216cf602892a
Gerrit-Change-Number: 19223
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200712/1f3062f5/attachment.htm>


More information about the gerrit-log mailing list