Python Forum
DEC pack, unpack and disk-images
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DEC pack, unpack and disk-images
#15
(Jun-16-2024, 06:43 PM)Curbie Wrote: Is the "table" variable in Gribouillis's code rebuilt every use (through prepare_table()) or is a "static" variable or does python have some sort of smart pseudo-static assignment?
the function prepare_table() is only called once when the statement
table = prepare_table()
is executed. This takes 39 microseconds on my computer.

You could go faster by assigning directly the result in the code
table = b'\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x00\x7f\x7f\x7f\x1c\x1d\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x1b\x7f\x1e\x1f !"#$%&\'\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x7f\x7f\x7f\x7f\x7f\x7f\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f\x7f'
The 'table' variable has a 256 bytes string value.

'table' is a global variable in this code. Global variables are stored in a global dictionary. You can consider them static variables.
« We can solve any problem by introducing an extra level of indirection »
Reply


Messages In This Thread
DEC pack, unpack and disk-images - by Curbie - Jun-03-2024, 06:57 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-04-2024, 03:43 AM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-04-2024, 04:06 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-06-2024, 04:40 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-07-2024, 06:45 AM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-08-2024, 10:23 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-10-2024, 12:06 AM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-16-2024, 06:43 PM
RE: DEC pack, unpack and disk-images - by Gribouillis - Jun-16-2024, 08:16 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-16-2024, 09:41 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-17-2024, 09:07 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-17-2024, 09:08 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-18-2024, 06:52 AM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-18-2024, 11:37 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-19-2024, 03:31 PM
RE: DEC pack, unpack and disk-images - by Curbie - Jun-20-2024, 04:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Too much values to unpack actualpy 3 657 Feb-11-2024, 05:38 PM
Last Post: deanhystad
  Hard disk structure like a file selection dialog malonn 2 945 Aug-09-2023, 09:14 PM
Last Post: malonn
  unpack dict menator01 1 1,336 Apr-09-2022, 03:10 PM
Last Post: menator01
  ValueError: not enough values to unpack (expected 4, got 1) vlearner 2 6,595 Jan-28-2022, 06:36 PM
Last Post: deanhystad
  JS Buffer.from VS struct.pack DreamingInsanity 3 2,668 Apr-05-2021, 06:27 PM
Last Post: DreamingInsanity
  [SOLVED] [geopy] "ValueError: too many values to unpack (expected 2)" Winfried 2 3,057 Mar-30-2021, 07:01 PM
Last Post: Winfried
  Cannot unpack non-iterable NoneType object, i would like to ask for help on this. Jadiac 3 9,182 Oct-18-2020, 02:11 PM
Last Post: Jadiac
  subprogram issues: cannot unpack non-iterable function object error djwilson0495 13 6,407 Aug-20-2020, 05:53 PM
Last Post: deanhystad
  How to Calculate CPU, Disk, Memory and Network utilization rate skvivekanand 1 2,157 Jun-16-2020, 08:53 PM
Last Post: jefsummers
  struct.unpack failed Roro 2 3,528 Jun-13-2020, 05:28 PM
Last Post: DreamingInsanity

Forum Jump:

User Panel Messages

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