I am trying to speed up my script. It basically reads a pcap file with Velodyne\'s Lidar HDL-32 information and allows me to get X, Y, Z, and Intensity values. I have profiled m
You can unpack the raw distanceInformation
and intensity
values together in one call. Especially because you're just putting them into a list together: that's what unpack()
does when it unpacks multiple values. In your case, you need to then multiple the distanceInformation
by 0.002
, but you might save time by leaving this until later, because you can use iter_unpack() to parse the whole list of raw pairs in one call. That function gives you a generator, which can be sliced with itertools.islice() and then turned into a list. Something like this:
laser_iter = struct.iter_unpack('
Unfortunately this is a little harder to read, so you might want to find a way to spread this out into more lines of code, with more descriptive variable names, or add a comment for the future when you forget why you wrote this…