[Python-talk] Profile results... Better pack?
bruce.labitt at autoliv.com
bruce.labitt at autoliv.com
Thu Oct 15 14:24:04 EDT 2009
kent3737 at gmail.com wrote on 10/15/2009 12:58:47 PM:
> On Thu, Oct 15, 2009 at 11:50 AM, <bruce.labitt at autoliv.com> wrote:
>
> > I guess first order of business is to work on packing...
> >
> > Is there a faster packer? I need to generate a string that is the
> > concatenation of:
> >
> > 1 16 bit number byte swapped + 1084200 doubles byte swapped
> >
> > The byte swapping is to get into network order.
>
> Can you show your code? I suggest you post this specific question to
> comp.lang.python with a code sample of what you are doing now. Even
> better would be a short, standalone program that demonstrates the
> timing. That newsgroup loves optimization questions.
>
I don't see why not.
Do you have to sign up to post?
I don't know how to do the random number generation in straight python...
I think this is a CME (complete minimal example).
# ===============================================
from numpy import random
from struct import pack
import time
lenfft = 10084200
sigma = 0.1
stim = random.normal(0., sigma, lenfft) # 10084200 gaussian random numbers
(doubles)
fmt = '!h'+str(stim.size)+'d' # makes fmt = '!h10084200d'
cmd = 4
startTime = time.time()
packdat = pack( fmt, cmd, *stim )
elapsed = time.time() - startTime
print 'Time to pack elements ', elapsed
# ==============================================
> > Can I use the module array?
>
> It looks promising, it does have byteswap() and tofile() methods...
>
> Kent
******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail. Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************
More information about the Python-talk
mailing list