dissect.cstruct 5.0.dev11__tar.gz → 5.0.dev12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/PKG-INFO +1 -1
  2. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/PKG-INFO +1 -1
  3. dissect_cstruct-5.0.dev12/dissect.cstruct.egg-info/scm_version.json +8 -0
  4. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_benchmark.py +38 -38
  5. dissect_cstruct-5.0.dev11/dissect.cstruct.egg-info/scm_version.json +0 -8
  6. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/.git-blame-ignore-revs +0 -0
  7. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/.gitattributes +0 -0
  8. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/CHANGELOG.md +0 -0
  9. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/COPYRIGHT +0 -0
  10. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/LICENSE +0 -0
  11. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/MANIFEST.in +0 -0
  12. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/README.md +0 -0
  13. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/__init__.py +0 -0
  14. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/bitbuffer.py +0 -0
  15. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/compiler.py +0 -0
  16. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/cstruct.py +0 -0
  17. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/exception.py +0 -0
  18. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/expression.py +0 -0
  19. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/lexer.py +0 -0
  20. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/parser.py +0 -0
  21. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/tools/__init__.py +0 -0
  22. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/tools/stubgen.py +0 -0
  23. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/__init__.py +0 -0
  24. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/base.py +0 -0
  25. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/char.py +0 -0
  26. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/enum.py +0 -0
  27. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/flag.py +0 -0
  28. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/int.py +0 -0
  29. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/leb128.py +0 -0
  30. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/packed.py +0 -0
  31. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/pointer.py +0 -0
  32. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/structure.py +0 -0
  33. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/void.py +0 -0
  34. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/types/wchar.py +0 -0
  35. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect/cstruct/util.py +0 -0
  36. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
  37. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
  38. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/entry_points.txt +0 -0
  39. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/requires.txt +0 -0
  40. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/scm_file_list.json +0 -0
  41. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/dissect.cstruct.egg-info/top_level.txt +0 -0
  42. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/examples/disk.py +0 -0
  43. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/examples/mirai.py +0 -0
  44. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/examples/pe.py +0 -0
  45. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/examples/protobuf.py +0 -0
  46. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/examples/secdesc.py +0 -0
  47. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/pyproject.toml +0 -0
  48. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/setup.cfg +0 -0
  49. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/__init__.py +0 -0
  50. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/_data/testdef.txt +0 -0
  51. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/_docs/Makefile +0 -0
  52. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/_docs/__init__.py +0 -0
  53. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/_docs/conf.py +0 -0
  54. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/_docs/index.rst +0 -0
  55. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/conftest.py +0 -0
  56. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_align.py +0 -0
  57. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_annotations.py +0 -0
  58. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_basic.py +0 -0
  59. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_bitbuffer.py +0 -0
  60. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_bitfield.py +0 -0
  61. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_compiler.py +0 -0
  62. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_ctypes.py +0 -0
  63. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_expression.py +0 -0
  64. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_lexer.py +0 -0
  65. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_parser.py +0 -0
  66. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_tools_stubgen.py +0 -0
  67. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_base.py +0 -0
  68. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_char.py +0 -0
  69. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_custom.py +0 -0
  70. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_enum.py +0 -0
  71. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_flag.py +0 -0
  72. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_int.py +0 -0
  73. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_leb128.py +0 -0
  74. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_packed.py +0 -0
  75. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_pointer.py +0 -0
  76. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_structure.py +0 -0
  77. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_union.py +0 -0
  78. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_void.py +0 -0
  79. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_types_wchar.py +0 -0
  80. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/test_utils.py +0 -0
  81. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tests/utils.py +0 -0
  82. {dissect_cstruct-5.0.dev11 → dissect_cstruct-5.0.dev12}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.cstruct
3
- Version: 5.0.dev11
3
+ Version: 5.0.dev12
4
4
  Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License-Expression: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.cstruct
3
- Version: 5.0.dev11
3
+ Version: 5.0.dev12
4
4
  Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License-Expression: Apache-2.0
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "5.0.dev0",
3
+ "distance": 12,
4
+ "node": "gc55e3235cd839183a456ec1fd6d5f9d792668223",
5
+ "dirty": true,
6
+ "branch": "main",
7
+ "node_date": "2026-11-04"
8
+ }
@@ -11,15 +11,32 @@ from dissect.cstruct.lexer import tokenize
11
11
  from dissect.cstruct.parser import CStyleParser, _join_line_continuations
12
12
 
13
13
  if TYPE_CHECKING:
14
+ from collections.abc import Callable
15
+
14
16
  from pytest_benchmark.fixture import BenchmarkFixture
15
17
 
16
18
  from dissect.cstruct.cstruct import cstruct
17
19
  from dissect.cstruct.lexer import Token
20
+ from dissect.cstruct.types import BaseType
21
+
22
+
23
+ @pytest.fixture(params=["read", "write"])
24
+ def read_or_write(request: pytest.FixtureRequest, benchmark: BenchmarkFixture) -> Callable:
25
+ """Benchmark parsing with the given function, or writing the value that it parses."""
26
+
27
+ def run(parse: Callable[[], BaseType]) -> None:
28
+ if request.param == "read":
29
+ benchmark(parse)
30
+ else:
31
+ obj = parse()
32
+ benchmark(lambda: obj.dumps())
33
+
34
+ return run
18
35
 
19
36
 
20
37
  @pytest.mark.benchmark
21
- def test_benchmark_basic(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
22
- """Benchmark the parsing of a simple struct with both the compiled and interpreted backends."""
38
+ def test_benchmark_basic(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
39
+ """Benchmark the parsing and writing of a simple struct with both the compiled and interpreted backends."""
23
40
  cdef = """
24
41
  struct test {
25
42
  uint32 a;
@@ -30,12 +47,12 @@ def test_benchmark_basic(cs: cstruct, compiled: bool, benchmark: BenchmarkFixtur
30
47
  """
31
48
  cs.load(cdef, compiled=compiled)
32
49
 
33
- benchmark(lambda: cs.test(b"\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x04"))
50
+ read_or_write(lambda: cs.test(b"\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x04"))
34
51
 
35
52
 
36
53
  @pytest.mark.benchmark
37
- def test_benchmark_union(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
38
- """Benchmark the parsing of a simple union with both the compiled and interpreted backends."""
54
+ def test_benchmark_union(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
55
+ """Benchmark the parsing and writing of a simple union with both the compiled and interpreted backends."""
39
56
  cdef = """
40
57
  union test {
41
58
  uint32 a;
@@ -46,12 +63,12 @@ def test_benchmark_union(cs: cstruct, compiled: bool, benchmark: BenchmarkFixtur
46
63
  """
47
64
  cs.load(cdef, compiled=compiled)
48
65
 
49
- benchmark(lambda: cs.test(b"\x01\x02\x03\x04\x05\x06\x07\x08"))
66
+ read_or_write(lambda: cs.test(b"\x01\x02\x03\x04\x05\x06\x07\x08"))
50
67
 
51
68
 
52
69
  @pytest.mark.benchmark
53
- def test_benchmark_union_nested(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
54
- """Benchmark the parsing of a union with nested structures with both the compiled and interpreted backends."""
70
+ def test_benchmark_union_nested(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
71
+ """Benchmark the parsing and writing of a union with nested structures with both backends."""
55
72
  cdef = """
56
73
  union test {
57
74
  struct {
@@ -68,12 +85,12 @@ def test_benchmark_union_nested(cs: cstruct, compiled: bool, benchmark: Benchmar
68
85
  """
69
86
  cs.load(cdef, compiled=compiled)
70
87
 
71
- benchmark(lambda: cs.test(b"\x01\x02\x03\x04\x05\x06\x07\x08"))
88
+ read_or_write(lambda: cs.test(b"\x01\x02\x03\x04\x05\x06\x07\x08"))
72
89
 
73
90
 
74
91
  @pytest.mark.benchmark
75
- def test_benchmark_union_array(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
76
- """Benchmark the parsing of an array of unions with both the compiled and interpreted backends."""
92
+ def test_benchmark_union_array(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
93
+ """Benchmark the parsing and writing of an array of unions with both the compiled and interpreted backends."""
77
94
  cdef = """
78
95
  union test {
79
96
  uint32 a;
@@ -83,7 +100,7 @@ def test_benchmark_union_array(cs: cstruct, compiled: bool, benchmark: Benchmark
83
100
  cs.load(cdef, compiled=compiled)
84
101
 
85
102
  buf = bytes(range(64))
86
- benchmark(lambda: cs.test[16](buf))
103
+ read_or_write(lambda: cs.test[16](buf))
87
104
 
88
105
 
89
106
  @pytest.mark.benchmark
@@ -241,8 +258,8 @@ def test_benchmark_lexer_and_parser(cs: cstruct, benchmark: BenchmarkFixture) ->
241
258
 
242
259
 
243
260
  @pytest.mark.benchmark
244
- def test_benchmark_nested_dynamic(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
245
- """Benchmark the parsing of a realistic struct with nested structs and dynamically sized arrays."""
261
+ def test_benchmark_nested_dynamic(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
262
+ """Benchmark the parsing and writing of a realistic struct with nested structs and dynamically sized arrays."""
246
263
  cs.load(_BENCHMARK_CDEF, compiled=compiled)
247
264
 
248
265
  buf = (
@@ -254,12 +271,12 @@ def test_benchmark_nested_dynamic(cs: cstruct, compiled: bool, benchmark: Benchm
254
271
  + b"\x15\x00\x00\x00" * 4 # Sid.SubAuthority
255
272
  )
256
273
 
257
- benchmark(lambda: cs.ACCESS_ALLOWED_OBJECT_ACE(buf))
274
+ read_or_write(lambda: cs.ACCESS_ALLOWED_OBJECT_ACE(buf))
258
275
 
259
276
 
260
277
  @pytest.mark.benchmark
261
- def test_benchmark_enum_flag_bits(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
262
- """Benchmark the parsing of a struct with enums, flags and bit fields."""
278
+ def test_benchmark_enum_flag_bits(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
279
+ """Benchmark the parsing and writing of a struct with enums, flags and bit fields."""
263
280
  cdef = """
264
281
  enum Type : uint16 {
265
282
  A = 1,
@@ -282,7 +299,7 @@ def test_benchmark_enum_flag_bits(cs: cstruct, compiled: bool, benchmark: Benchm
282
299
  """
283
300
  cs.load(cdef, compiled=compiled)
284
301
 
285
- benchmark(lambda: cs.test(b"\x01\x00\x05\x00\x34\x12\x01\x00\x00\x00"))
302
+ read_or_write(lambda: cs.test(b"\x01\x00\x05\x00\x34\x12\x01\x00\x00\x00"))
286
303
 
287
304
 
288
305
  @pytest.mark.benchmark
@@ -302,8 +319,8 @@ def test_benchmark_flag_operators(cs: cstruct, benchmark: BenchmarkFixture) -> N
302
319
 
303
320
 
304
321
  @pytest.mark.benchmark
305
- def test_benchmark_strings(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
306
- """Benchmark the parsing of a struct with fixed size and null-terminated strings."""
322
+ def test_benchmark_strings(cs: cstruct, compiled: bool, read_or_write: Callable) -> None:
323
+ """Benchmark the parsing and writing of a struct with fixed size and null-terminated strings."""
307
324
  cdef = """
308
325
  struct test {
309
326
  wchar name[8];
@@ -320,7 +337,7 @@ def test_benchmark_strings(cs: cstruct, compiled: bool, benchmark: BenchmarkFixt
320
337
  + b"\x00\x00"
321
338
  )
322
339
 
323
- benchmark(lambda: cs.test(buf))
340
+ read_or_write(lambda: cs.test(buf))
324
341
 
325
342
 
326
343
  @pytest.mark.benchmark
@@ -350,23 +367,6 @@ def test_benchmark_array(cs: cstruct, benchmark: BenchmarkFixture) -> None:
350
367
  benchmark(lambda: cs.uint32[16](buf))
351
368
 
352
369
 
353
- @pytest.mark.benchmark
354
- def test_benchmark_dumps(cs: cstruct, benchmark: BenchmarkFixture) -> None:
355
- """Benchmark the writing of a simple struct."""
356
- cdef = """
357
- struct test {
358
- uint32 a;
359
- uint64 b;
360
- uint16 c;
361
- uint8 d;
362
- };
363
- """
364
- cs.load(cdef)
365
- obj = cs.test(b"\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x04")
366
-
367
- benchmark(lambda: obj.dumps())
368
-
369
-
370
370
  @pytest.mark.benchmark
371
371
  def test_benchmark_load_and_read(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
372
372
  """Benchmark loading struct definitions and reading one struct, which includes any (lazy) compilation."""
@@ -1,8 +0,0 @@
1
- {
2
- "tag": "5.0.dev0",
3
- "distance": 11,
4
- "node": "g24a5ab47fcef207013db7f6f5769efb4bf37a697",
5
- "dirty": true,
6
- "branch": "main",
7
- "node_date": "2026-11-02"
8
- }