Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6166433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:20:16+00:00 2026-05-23T22:20:16+00:00

I just read about the *args and **kwargs notation in python and decided to

  • 0

I just read about the *args and **kwargs notation in python and decided to use it with my functions that use struct.pack as such:

def pack_floats(*args):

   return struct.pack('%df' %len(args), args)

But of course, it doesn’t work because args is a tuple. If I wanted to pack three numbers, I would call pack as such

struct.pack('3f', 1, 2, 3)

Alternatively I could just run it through a loop and pack one number at a time, but I don’t know whether there is any performance difference between one value at a time vs all values at a time.

Is there a way to write the pack_floats function without calling the pack function inside a loop?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:20:18+00:00Added an answer on May 23, 2026 at 10:20 pm
    >>> import struct
    >>> def pack_floats(*args):
    ...     return struct.pack('%df' %len(args), *args)
    ... 
    >>> pack_floats(0.1,1.2,2.3)
    '\xcd\xcc\xcc=\x9a\x99\x99?33\x13@'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just got Delphi 2009 and have previously read some articles about modifications that
I've just read about MVC3's new CompareAttribute that you can apply to a model's
I have just read about http://marc.info/?l=php-internals&m=131031747409271&w=2 . I use mysql_query in all my php
I just read this post about why new-line warnings exist, but to be honest
I just started to read about this new technology... Does someone have some knowledge
Just finished read this post by Greg Young, where he is talking about Microsoft
I've just read about the Single Responsibility Principle and at one point Robert C.
I've just read tutorial about enums and have one question. I've studied example: public
I just read this annoucement about Apple lifting restrictions on its third-party developer guidelines
I just read little bit about macro and was trying to create the one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.