New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type consolidation and improvements #5319
base: master
Are you sure you want to change the base?
Conversation
9874ccd
to
26551fe
Compare
My first reaction is that I really do not like the renaming of absolute.compute_raw to pixels. To me, the name "pixels" refers to an array of pixels, and not a position. 200709d should go away - it seems more confusing to me. (Or perhaps become absolute with a second parameter.) I'm not in love with compute_raw, either, but I think 'pixels' is worse. |
eb05eda - I like the idea of this, but I think it should probably be renpy.display.types, since it only has display-related types. aeb4586 - This seems wrong. If someone was to write:
They'd get position with relative set to 0.5, which is very confusing. eae1b6d - Fine. 16be044 - Fine. cba2c29 - Fine. c15f39c - Seems unsafe, because of aeb4586. 09490b7 - As we discussed on dev, having a type's constructor return an instance of a different type is very confusing. I like position_or_none, since it matches the way I think about positions. 8d82878 - Fine. 200709d - As discussed, I really don't like the name pixels. I do like absolute, though I'm not a huge fan of absolute.compute_raw as a name. I'm wondering if it makes sense to replace absolute.compute_raw with absolute.compute, and speed absolute.compute up so we can just used it everywhere. 26551fe - Fine. ba1bf44 - Fine, but we may not want to do this everywhere, only in cases like this where it's really obvious what's absolute and what's relative. |
72a5ae0
to
ba1bf44
Compare
The content of the new types module is purely lift and shift, with the exception of references to other moved types. Some functions and methods have been reordered but the code is unchanged.
This avoids other code needing to know or care about which operators are implemented directly and thus more performant and which are amalgams of other operators with additional overhead.
This is used by the transform interpolation code to identify which properties have changed. The lack of this method causes it to run no-op interpolations.
The rationale for this is that they didn't serve their intended purpose, and somewhat misleading. They only called by interpolation, and in such a way that the argument could never be None. In 8.2 a special case was added to spline interpolation which used one of these functions directly, however the additional None handling failed to make the result any more usable. In order to address this in a more useful way, and align with non-spline interpolation, None values will now be treated as zero.
Same logic as for position, other code shouldn't have to worry which operators have first class support, and there are less mental hoops to jump through when we look back from years in the future.
Merges the DualAngle type and dualangle function removing the burden on calling code to appreciate the nuance and simply ask for a dualangle.
ba1bf44
to
1e0b9bb
Compare
This is addressed by making the first argument of Covered by the adjustment above.
This has been replaced with 6a570b4, which seeks to simplify the ATL property type spec to what is functionally useful (see commit message for more details on why the
This has been done, moving to and optimising
The calling sites affected by this use variable names making it clear which is which, so I think this is fine as long as we're conscious of the same concern when it comes to any future uses. Additional changes include:
I don't love the pickle compat, but after trying multiple approaches this was the one that worked, was the most sane, and didn't add confusion to other parts of the repo. I have the beginnings of an idea for general improvements to inter-version pickle compat, however they are out of scope for this PR. |
We got away without defining __getnewargs__ in 8.2 because we didn't require arguments to __new__, but probably still ought to have done it. As pickled 8.2 types don't have the necessary arguments available to them, they require compat wrappers during unpickling.
1e0b9bb
to
f6bf7f9
Compare
Recommend commit-by-commit review using commit messages as your guide.
Headlines:
absolute
,position
, andDualAngle
types to newrenpy.display.types
module, along with various coercion functions.position
type negating need forposition.from_any
.==
and!=
operators toposition
to aid transform change detection code.position_or_none
in favour of allowingposition
to gracefully handleNone
itself.DualAngle.from_any
to module leveldualangle
and optimise type checks.absolute.compute_raw
to 'absolute.compute' and optimised type checks.Commit messages have a little more detail, but there's anything you feel requires more explanation give me a shout. :)