File: init

package info (click to toggle)
python-orjson 3.10.7-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 4,180 kB
  • sloc: ansic: 11,270; python: 6,658; sh: 135; makefile: 9
file content (37 lines) | stat: -rwxr-xr-x 697 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import multiprocessing.pool
import sys

import orjson

NUM_PROC = 16

TEST_MESSAGE = "parallel import of orjson running..."


class Custom:
    pass


def default(_):
    return None


def func(_):
    orjson.dumps(Custom(), option=orjson.OPT_SERIALIZE_NUMPY, default=default)
    orjson.loads(b'{"a":1,"b":2,"c":3}')


def main():
    sys.stdout.write(TEST_MESSAGE)
    sys.stdout.flush()
    with multiprocessing.pool.ThreadPool(processes=NUM_PROC) as pool:
        pool.map(func, (i for i in range(0, NUM_PROC)))
    sys.stdout.write(f"\r{TEST_MESSAGE} ok\n")
    sys.stdout.flush()


if __name__ == "__main__":
    main()