Python Forum
binary data in source code form
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
binary data in source code form
#5
(May-23-2017, 05:49 AM)Ofnuts Wrote: If it's binary, don' t put it in a string. Use a byte array.

that's really what i mean.  it's still written like a string.  what i am wondering is if ints could be a more efficient way to express it.  my goal is to make the file that looks like python source code as small as possible.

data = b'\000\377\377\000\000\377\377\003\000\177\177\005\006\377\377\001'
vs.

data = ( 72056494543077123, 35886981611257601 )
vs.

data = 1329207713684792564064364514848538369
it looks like int would be more efficient.

(Jun-01-2017, 09:51 PM)nilamo Wrote: Base64 is how binary images are stored in source fairly frequently.  Not sure if that helps you or not.
that is one of the first ways i looked at. but it is rather inefficient. it's better than hexadecimal, but only by 50% more. in terms of the convenience of available tools for conversion, it is a good choice. but look at how you would embed it in source code. you would have a big string of the base64 characters and the calls to convert that string. that would take up a lot of source code space.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
binary data in source code form - by Skaperen - May-23-2017, 05:18 AM
RE: binary data in source code form - by Ofnuts - May-23-2017, 05:49 AM
RE: binary data in source code form - by Skaperen - Jun-02-2017, 02:21 AM
RE: binary data in source code form - by Larz60+ - May-23-2017, 11:21 AM
RE: binary data in source code form - by nilamo - Jun-01-2017, 09:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  UART write binary code trix 3 531 Apr-28-2024, 04:57 PM
Last Post: deanhystad
  delivery exe without source code py loky62 2 490 Apr-04-2024, 05:47 PM
Last Post: loky62
  Help with to check an Input list data with a data read from an external source sacharyya 3 660 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  Algorithm for extracting comments from Python source code Pavel1982 6 882 Feb-28-2024, 09:52 PM
Last Post: Pavel1982
  Sending data from the form to DB quisatz 5 1,556 Sep-27-2023, 04:58 PM
Last Post: quisatz
  Python Code for Preorder Traversal of a Binary Tree Bolt 1 726 Sep-22-2023, 09:32 AM
Last Post: Gribouillis
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 8,164 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  Unable to request image from FORM Data usman 0 1,073 Aug-18-2022, 06:23 PM
Last Post: usman
  No Module found in other directory than source code [SOLVED] AlphaInc 1 2,229 Nov-10-2021, 04:34 PM
Last Post: AlphaInc
  Generating classes diagram from source code Pavel_47 3 6,097 Oct-01-2021, 03:31 AM
Last Post: Lou

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020