forked from llvm/circt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OM] Simplify the Python instantiate API to just return Objects. (llv…
…m#5400) This API previously accepted a Python dataclass as input, and used it as a template to guide the logic to pull fields out of the instantiated Object and build an instance of the requested dataclass. This allowed the API to be strongly typed, by accepting a dataclass type as input and returning an instance of that dataclass as output. However, this requires the user to specify a-priori what fields should be present in the resulting Object, and this may not always be known. By simply returning an Object, and adding the appropriate Python conversions to Object's __getattr__, we can generically return Objects that behave just like the previous dataclasses, without specifying the fields up front. This also avoids rewrapping the Objects in dataclasses. In the future, we can add back a similar form of type safety when this would be useful, potentially using Protocols similarly to how dataclasses were used as a template before.
- Loading branch information
1 parent
49f73eb
commit c5aff9a
Showing
3 changed files
with
45 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters