Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109294

Re: Efficient handling of fast, real-time hex data

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Michael Torrie <torriem@gmail.com>
Newsgroups comp.lang.python
Subject Re: Efficient handling of fast, real-time hex data
Date Tue, 31 May 2016 18:35:44 -0600
Lines 20
Message-ID <mailman.60.1464741354.1839.python-list@python.org> (permalink)
References <24081cb5-c5e2-44e4-948f-ecf01ebaf7e6@googlegroups.com> <816aa3d4-352d-0289-f9b5-00cd8798c9ae@gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de zi+GODfA3gtkMNbztPovVAM2hH3cYZckJuhUYC3/1rng==
Return-Path <torriem+gmail@torriefamily.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'python,': 0.02; 'python': 0.10; 'at.': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:handling': 0.16; 'wrote:': 0.16; 'byte': 0.18; 'bytes': 0.18; 'integer': 0.18; 'struct': 0.22; 'bit': 0.23; 'header:In- Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'module.': 0.27; 'sequence': 0.27; 'them?': 0.29; 'array': 0.29; "i'm": 0.30; 'task': 0.30; 'probably': 0.31; 'url:python': 0.33; 'message- id:@gmail.com': 0.34; 'quickly': 0.34; 'so,': 0.35; 'could': 0.35; 'subject:time': 0.35; 'but': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'thanks': 0.37; 'received:org': 0.37; 'thought': 0.37; 'things': 0.38; 'doing': 0.38; 'received:192': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'charset:windows-1252': 0.62; 'packing': 0.84; 'imagine': 0.96
X-Virus-Scanned amavisd-new at torriefamily.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0
In-Reply-To <24081cb5-c5e2-44e4-948f-ecf01ebaf7e6@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <816aa3d4-352d-0289-f9b5-00cd8798c9ae@gmail.com>
X-Mailman-Original-References <24081cb5-c5e2-44e4-948f-ecf01ebaf7e6@googlegroups.com>
Xref csiph.com comp.lang.python:109294

Show key headers only | View raw


On 05/31/2016 06:20 PM, jladasky@itu.edu wrote:
> So, how can I take the byte sequence <0x01 0x02 0x03 0x04 0x05 0x06
> \n> that Serial.readline() returns to me, and QUICKLY turn it into
> three integer values, 258, 772, and 1286?  Better yet, can I write
> these bytes directly into an array (numpy is an option), since I'm
> going to have a lot of them?

I think you might want to use the struct module. It's designed for this
kind of packing and unpacking:

https://docs.python.org/3/library/struct.html

> I never thought I would find a task that's easier for me to imagine
> doing in C than in Python, but at the moment this is one.  Thanks for
> any suggestions!

Byte and bit twiddling are things that C has always been fast at.  But I
think Python probably could do it.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Efficient handling of fast, real-time hex data jladasky@itu.edu - 2016-05-31 17:20 -0700
  Re: Efficient handling of fast, real-time hex data Michael Torrie <torriem@gmail.com> - 2016-05-31 18:35 -0600
    Re: Efficient handling of fast, real-time hex data jladasky@itu.edu - 2016-05-31 18:26 -0700
  Re: Efficient handling of fast, real-time hex data Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-06-01 01:01 +0000
    Re: Efficient handling of fast, real-time hex data jladasky@itu.edu - 2016-05-31 18:23 -0700
  Re: Efficient handling of fast, real-time hex data Paul Rubin <no.email@nospam.invalid> - 2016-05-31 21:16 -0700
  Re: Efficient handling of fast, real-time hex data Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-01 16:37 +1200
    Re: Efficient handling of fast, real-time hex data jladasky@itu.edu - 2016-06-01 11:03 -0700
      Re: Efficient handling of fast, real-time hex data Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-06-02 18:50 +1200
        Re: Efficient handling of fast, real-time hex data alister <alister.ware@ntlworld.com> - 2016-06-02 08:13 +0000
          Re: Efficient handling of fast, real-time hex data Gene Heskett <gheskett@wdtv.com> - 2016-06-02 05:41 -0400
            Re: Efficient handling of fast, real-time hex data alister <alister.ware@ntlworld.com> - 2016-06-02 12:30 +0000

csiph-web