How far are we from `@dataclass`
- Dominant language
- C++
- Stars
- 462
- Forks
- 99
- Avg merge
- 8h 37m
- Merged PRs (30d)
- 73
Description
Resolved by
- https://github.com/apache/tvm-ffi/pull/477
- https://github.com/apache/tvm-ffi/pull/499
- https://github.com/apache/tvm-ffi/pull/555
- https://github.com/apache/tvm-ffi/pull/556
-----------------------------------------------------------------------
- [x] Init: generates `__init__` (we implemented some of the logics in @c_class)
- ✅ flag `init=True` in `@dataclass`
- ✅ flag `init=True` in `dataclasses.field`
- ✅ run `__post_init__` if presents done
- ✅ default=MISSING, default_factory=MISSING in `dataclasses.field`
- ❌ InitVar
- ✅ ClassVar
- ✅ `kw_only=False` in `@dataclass`
- ✅ `kw_only=MISSING` in `dataclasses.field`
- ✅ dataclasses.KW_ONLY
- [x] Repr: generates `__repr__`
- ✅ flag `repr=True` in `@dataclass`
- ✅ flag `repr=True` in `dataclasses.field`
- [x] Copy: Generate copy interface
- ✅ `def __copy__(self)`
- ✅ `def __deepcopy__(self, memo)`
- ✅ `def __replace__(self, **changes)` and dataclasses.replace
- [x] Equality
- ✅ `eq=True` in `@dataclass`: generates `__eq__` and `__ne__`
- [x] Comparison
- ✅ `order=False` in `@dataclass`: generates `__lt__`, `__le__`, `__gt__`, and `__ge__`,
- ✅ `compare=True` in `dataclasses.field`
- [x] Mutability and extra slots:
- ✅ `slots`
- ❌ `frozen=False`: mutability
- ❌ `weakref_slot=False`
- [x] Hashing
- ❌ `unsafe_hash=False`
- ✅ hash=None
Misc
- [x] dataclasses.replace
- [x] dataclasses.fields
- [x] dataclasses.is_dataclass
- [x] dataclasses.asdict
- [x] dataclasses.astuple
- [x] `match_args=True` in `@dataclass`
- [ ] metadata=None in `dataclasses.field`
- [ ] doc=None in `dataclasses.field`
- [ ] dataclasses.make_dataclass
Contributor guide
Research direction
Review pull requests 477, 499, 555, and 556 first, then compare their changes with the remaining items in the dataclasses checklist. The issue is done only when the listed missing features, including InitVar, mutability, weakref_slot, unsafe_hash, metadata, doc, and make_dataclass, are addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 20/100