Skip to content

Commit 39679f2

Browse files
committed
Measure impact of exposing StructMeta
1 parent 0191e29 commit 39679f2

File tree

5 files changed

+142
-227
lines changed

5 files changed

+142
-227
lines changed

.github/workflows/ci.yml

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ jobs:
4545
- name: Install command runner
4646
run: uv tool install rust-just
4747

48-
- name: Install static analysis dependencies
49-
run: just env-sync hooks
48+
# - name: Install static analysis dependencies
49+
# run: just env-sync hooks
5050

51-
- name: Run hooks
52-
run: just hooks-check
51+
# - name: Run hooks
52+
# run: just hooks-check
5353

54-
- name: Install testing dependencies
55-
run: just env-sync test
54+
# - name: Install testing dependencies
55+
# run: just env-sync test
5656

57-
- name: Run tests
58-
run: just test-all
57+
# - name: Run tests
58+
# run: just test-all
5959

6060
- name: Build source distribution
6161
id: build-sdist
@@ -97,76 +97,76 @@ jobs:
9797
- name: Checkout code
9898
uses: actions/checkout@v5
9999

100-
- name: Load environment file
101-
uses: ./.github/actions/load-env
102-
103-
- name: Install Python
104-
uses: actions/setup-python@v6
105-
with:
106-
python-version: "${{ matrix.python-version }}"
107-
108-
- name: Install uv
109-
uses: astral-sh/setup-uv@v7
110-
111-
- name: Install command runner
112-
run: uv tool install rust-just
113-
114-
- name: Install testing dependencies
115-
env:
116-
MSGSPEC_SANITIZE: "true"
117-
MSGSPEC_COVERAGE: "true"
118-
run: just env-sync test
119-
120-
- name: Run tests with sanitizers
121-
env:
122-
PYTHONMALLOC: "malloc"
123-
ASAN_OPTIONS: "detect_leaks=0"
124-
run: >-
125-
LD_PRELOAD=`gcc -print-file-name=libasan.so`
126-
just env-run test coverage run -m pytest tests/unit -s
127-
128-
- name: Generate coverage files
129-
run: |-
130-
just env-run test coverage xml
131-
gcov -abcu `find build/temp*/ -name *.o`
132-
133-
- name: Upload coverage artifacts
134-
uses: actions/upload-artifact@v5
135-
with:
136-
name: coverage-${{ matrix.python-version }}-${{ matrix.os }}
137-
path: |-
138-
coverage.xml
139-
_core.c.gcov
140-
atof.h.gcov
141-
ryu.h.gcov
142-
if-no-files-found: error
143-
144-
upload-coverage:
145-
name: Upload coverage files to Codecov
146-
needs:
147-
- test
148-
runs-on: ubuntu-latest
149-
permissions:
150-
id-token: write
151-
152-
steps:
153-
- name: Checkout code
154-
uses: actions/checkout@v5
155-
156-
- name: Download coverage artifacts
157-
uses: actions/download-artifact@v5
158-
with:
159-
pattern: coverage-*
160-
path: coverage-files
161-
162-
- name: See the coverage files
163-
run: tree -sh coverage-files
164-
165-
- name: Upload Codecov
166-
uses: codecov/codecov-action@v5
167-
with:
168-
use_oidc: true
169-
directory: coverage-files
100+
# - name: Load environment file
101+
# uses: ./.github/actions/load-env
102+
103+
# - name: Install Python
104+
# uses: actions/setup-python@v6
105+
# with:
106+
# python-version: "${{ matrix.python-version }}"
107+
108+
# - name: Install uv
109+
# uses: astral-sh/setup-uv@v7
110+
111+
# - name: Install command runner
112+
# run: uv tool install rust-just
113+
114+
# - name: Install testing dependencies
115+
# env:
116+
# MSGSPEC_SANITIZE: "true"
117+
# MSGSPEC_COVERAGE: "true"
118+
# run: just env-sync test
119+
120+
# - name: Run tests with sanitizers
121+
# env:
122+
# PYTHONMALLOC: "malloc"
123+
# ASAN_OPTIONS: "detect_leaks=0"
124+
# run: >-
125+
# LD_PRELOAD=`gcc -print-file-name=libasan.so`
126+
# just env-run test coverage run -m pytest tests/unit -s
127+
128+
# - name: Generate coverage files
129+
# run: |-
130+
# just env-run test coverage xml
131+
# gcov -abcu `find build/temp*/ -name *.o`
132+
133+
# - name: Upload coverage artifacts
134+
# uses: actions/upload-artifact@v5
135+
# with:
136+
# name: coverage-${{ matrix.python-version }}-${{ matrix.os }}
137+
# path: |-
138+
# coverage.xml
139+
# _core.c.gcov
140+
# atof.h.gcov
141+
# ryu.h.gcov
142+
# if-no-files-found: error
143+
144+
# upload-coverage:
145+
# name: Upload coverage files to Codecov
146+
# needs:
147+
# - test
148+
# runs-on: ubuntu-latest
149+
# permissions:
150+
# id-token: write
151+
152+
# steps:
153+
# - name: Checkout code
154+
# uses: actions/checkout@v5
155+
156+
# - name: Download coverage artifacts
157+
# uses: actions/download-artifact@v5
158+
# with:
159+
# pattern: coverage-*
160+
# path: coverage-files
161+
162+
# - name: See the coverage files
163+
# run: tree -sh coverage-files
164+
165+
# - name: Upload Codecov
166+
# uses: codecov/codecov-action@v5
167+
# with:
168+
# use_oidc: true
169+
# directory: coverage-files
170170

171171
profile:
172172
name: Run profiling tests

.github/workflows/docs.yml

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,49 @@ jobs:
1313
- name: Checkout code
1414
uses: actions/checkout@v5
1515

16-
- name: Load environment file
17-
uses: ./.github/actions/load-env
18-
19-
- name: Install Python
20-
uses: actions/setup-python@v6
21-
with:
22-
python-version-file: pyproject.toml
23-
24-
- name: Install uv
25-
uses: astral-sh/setup-uv@v7
26-
27-
- name: Install command runner
28-
run: uv tool install rust-just
29-
30-
- name: Install dependencies
31-
run: just env-sync doc
32-
33-
- name: Build documentation
34-
run: just doc-build
35-
36-
- name: Restore link check cache
37-
uses: actions/cache@v4
38-
with:
39-
path: .lycheecache
40-
key: cache-lychee-${{ github.sha }}
41-
restore-keys: cache-lychee-
42-
43-
- name: Check links
44-
uses: lycheeverse/lychee-action@v2
45-
with:
46-
lycheeVersion: v0.21.0
47-
fail: true
48-
failIfEmpty: true
49-
token: "${{ github.token }}"
50-
args: >-
51-
--verbose
52-
--no-progress
53-
README.md
54-
docs/build
55-
56-
- name: Deploy
57-
uses: peaceiris/actions-gh-pages@v4
58-
if: github.ref == 'refs/heads/main'
59-
with:
60-
github_token: "${{ github.token }}"
61-
publish_dir: docs/build/html
16+
# - name: Load environment file
17+
# uses: ./.github/actions/load-env
18+
19+
# - name: Install Python
20+
# uses: actions/setup-python@v6
21+
# with:
22+
# python-version-file: pyproject.toml
23+
24+
# - name: Install uv
25+
# uses: astral-sh/setup-uv@v7
26+
27+
# - name: Install command runner
28+
# run: uv tool install rust-just
29+
30+
# - name: Install dependencies
31+
# run: just env-sync doc
32+
33+
# - name: Build documentation
34+
# run: just doc-build
35+
36+
# - name: Restore link check cache
37+
# uses: actions/cache@v4
38+
# with:
39+
# path: .lycheecache
40+
# key: cache-lychee-${{ github.sha }}
41+
# restore-keys: cache-lychee-
42+
43+
# - name: Check links
44+
# uses: lycheeverse/lychee-action@v2
45+
# with:
46+
# lycheeVersion: v0.21.0
47+
# fail: true
48+
# failIfEmpty: true
49+
# token: "${{ github.token }}"
50+
# args: >-
51+
# --verbose
52+
# --no-progress
53+
# README.md
54+
# docs/build
55+
56+
# - name: Deploy
57+
# uses: peaceiris/actions-gh-pages@v4
58+
# if: github.ref == 'refs/heads/main'
59+
# with:
60+
# github_token: "${{ github.token }}"
61+
# publish_dir: docs/build/html

src/msgspec/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
MsgspecError,
77
Raw,
88
Struct,
9-
StructMeta,
109
UnsetType,
1110
UNSET,
1211
NODEFAULT,

src/msgspec/__init__.pyi

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import enum
2-
from inspect import Signature
32
from typing import (
43
Any,
54
Callable,
@@ -21,51 +20,6 @@ from typing_extensions import dataclass_transform, Buffer
2120

2221
from . import inspect, json, msgpack, structs, toml, yaml
2322

24-
# PEP 673 explicitly rejects using Self in metaclass definitions:
25-
# https://peps.python.org/pep-0673/#valid-locations-for-self
26-
#
27-
# Typeshed works around this by using a type variable as well:
28-
# https://github.com/python/typeshed/blob/17bde1bd5e556de001adde3c2f340ba1c3581bd2/stdlib/abc.pyi#L14-L19
29-
_SM = TypeVar("_SM", bound="StructMeta")
30-
31-
class StructMeta(type):
32-
__struct_fields__: ClassVar[Tuple[str, ...]]
33-
__struct_defaults__: ClassVar[Tuple[Any, ...]]
34-
__struct_encode_fields__: ClassVar[Tuple[str, ...]]
35-
__match_args__: ClassVar[Tuple[str, ...]]
36-
@property
37-
def __signature__(self) -> Signature: ...
38-
@property
39-
def __struct_config__(self) -> structs.StructConfig: ...
40-
def __new__(
41-
mcls: Type[_SM],
42-
name: str,
43-
bases: Tuple[type, ...],
44-
namespace: Dict[str, Any],
45-
/,
46-
*,
47-
tag: Union[None, bool, str, int, Callable[[str], Union[str, int]]] = None,
48-
tag_field: Union[None, str] = None,
49-
rename: Union[
50-
None,
51-
Literal["lower", "upper", "camel", "pascal", "kebab"],
52-
Callable[[str], Optional[str]],
53-
Mapping[str, str],
54-
] = None,
55-
omit_defaults: bool = False,
56-
forbid_unknown_fields: bool = False,
57-
frozen: bool = False,
58-
eq: bool = True,
59-
order: bool = False,
60-
kw_only: bool = False,
61-
repr_omit_defaults: bool = False,
62-
array_like: bool = False,
63-
gc: bool = True,
64-
weakref: bool = False,
65-
dict: bool = False,
66-
cache_hash: bool = False,
67-
) -> _SM: ...
68-
6923
T = TypeVar("T")
7024

7125
class UnsetType(enum.Enum):
@@ -85,7 +39,7 @@ def field(*, default_factory: Callable[[], T], name: Optional[str] = None) -> T:
8539
@overload
8640
def field(*, name: Optional[str] = None) -> Any: ...
8741
@dataclass_transform(field_specifiers=(field,))
88-
class Struct(metaclass=StructMeta):
42+
class Struct:
8943
__struct_fields__: ClassVar[Tuple[str, ...]]
9044
__struct_config__: ClassVar[structs.StructConfig]
9145
__match_args__: ClassVar[Tuple[str, ...]]

0 commit comments

Comments
 (0)