Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add copy() method to datatype (#6269)
### Problem We have a lot of calls to the `CCompiler`, `CppCompiler`, and `Linker` constructors in `native_toolchain.py` to add extra cli arguments or environment variables, and we currently have to specify the value of every field of these constructors, even if we are only changing one or two of them. ### Solution - add a `copy(self, **kwargs)` method to `datatype` which creates a new object with any entries from `kwargs` applied. *this particular interface was inspired by scala case classes* - add testing for the new `copy()` method - consume `copy()` in `native_toolchain.py` ### Result When creating datatype objects derived from existing objects of the same type, only the changed fields need to be specified, improving the readability of the code in `native_toolchain.py`.
- Loading branch information
1 parent
492acb2
commit 89c6b40
Showing
3 changed files
with
50 additions
and
42 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