Conversation
8031918 to
e668a1e
Compare
…TraversableRenpyPath
…ified RenpyPath. This revised code for Renpy importer has revealed 15-20% better performance in "The Question" VN and "Tutorial" VN vs previous code. Tests were conducted with gc active.
This makes RenpyPath globally available inside renpy script files
|
@renpytom It's ready for review. |
|
I do like the idea of RenpyPath. I have a few questions about the implementation:
|
I decided, for methods which already exist in
I don't mind that. Where do you suggest me placing them?
I need a better clarification of what you mean related to load order.
It's not an advantage if this class is loaded earlier than this. Actually, it's only useful when used after |
|
@Andykl Please respond. |
|
I gave it a good thought and I will try to convey my reasoning. You propose to add RenpyPath as public API, so any decisions you made are gonna stuck for a good amount of years. It is much easier to iterate with functions because you can leave old one with bad interface or something as is and make a new function. But with class, it is more like "should be good first try". That thought was an implicit premise in my questions. I agree that "make it compatible with as many libraries that exist for pathlib as viable" is a good goal, so making signatues compatible is correct, but that reinforce my objection to inherit from PosixPath, because if library does At the same time, I think RenpyPath should be 100% compatiable with any other Ren'Py API that currently uses So, to sum this up, I think that RenpyPath should be inherited from About the class being in separate file, my reasoning is that your PR doubles the size of or something like that. I don't mind if you leave it as is, that's also something that Tom may decide one way or the other. |
With a class, you can leave the old method that had a bad interface as is and make a new method. I don't see how a class makes that worse, at that level. I do agree that methods create an explicit inter-dependency between them. However, this
However, that point is valid for the new methods I added. As a middle ground, I can start with separate functions (and using your new module idea, they'd be in the And on that 3rd one, I made extensive testing (which I didn't include in this PR) to ensure as-perfect behavior parity with
I think you meant "my objection to inherit from
If we provide support to execute, I'll use the If there's a need to normalize input from user into lower case and unicode folding for
I wonder if that cryptic can be mitigated with documentation. It is not API and it's only used for the internal representation.
I believe you mean them being the same file, as in, calling Assuming you meant
Given my explanation above, libraries can assume a However, if you are still uncertain, I'm ok with making a flavour like I did with my 2nd iteration and make it extend
I think we can move to a different file with RenpyPath as a module, no issues. About
I think sphinx doesn't like that. Complains both methods are the same. That's why I did the Thank you for the attention. |
|
Classes are not only methods. Yes, for extra methods we can always add a new one, but the devil in the details. Things that are tricky to change after class is exposed as public are - public attributes (if any), I will take a deeper look at python implementation of pathlib and your library and how it changed over time to see your iterations. It is great that you have a solid ground on the API. I want to tell that my comments are not deal breaker for your implementation, just my input, based on working with renpy and python overall, so that we can make better decision on what end user will get. Also I think it's important to note that I am currently working at free time on updating renpy to 3.14. I don't see any blockers for it to be ready for next renpy release, but can't be certain when it will be ready, so if I understand correctly your code will need to change after that. |
In the case of
I don't have a public git history of most of my iterations. But I can try to find what I have in my backups if you need it.
Thank you for clarifying 🙂. I agree. It's productive to discuss and make sure I didn't forget anything. I did extensive work on it but it's not rare for me to fo 99%, believing I did 100% and then someone calls me out of that 1% which I missed. Rarely it's more than a small thing to fix or some tweak but it happens more often at work than I wish it did.
There are optimizations I can do for 3.14. Some parts of it, such as Then I'll need to test again, to make sure all works as expected. But I'm not expecting any regressions. |
|
Moved back to draft waiting for python 3.14 and will implement the optimizations I already predicted I could do for 3.13 or higher. |
This is my first part in my 2-part effort to bring
RenpyPathto Ren'Py.This is about having a
PathLikeclass, which is as compatible as viable withPath's API as I reasonably could, while adding extra features which I see as advantageous for its users.This draft PR already has all the core concepts I want to introduce and the core changes I have planned.This PR has all the content planned for the first part I planned.
I've been testing and using this in Ren'Py VNs I have access to. Some with a few hundred files such as Tutorial and The Question and a few between 10K-140K file range (voice taking the majority of the count), some with
.pyfiles (Python libraries installed and present), some without. Assuming I didn't make any significant copy&paste mistakes between what I used and the master branch, it should work without any known issues at the moment.This code (except metadata) was fully written by me, however, AI was used. This code was "peer-reviewed" (within its limitations) by AI, most type annotations, unit tests and performance tests (not included) were written by AI, all with my strict supervision. Initial function/method documentation (the one in the first commit here) was some written by me, some by AI.
renpy.exports(i.e. making it available either asRenpyPath(preferred) orrenpy.RenpyPath.RenpyPathto a separate module.For the 2nd part, which will be a separate PR and discussion, I intend to replace the majority (but not all) internal calls to
renpy.list_files()to useRenpyPathinstead. As part of testing ifRenpyPathappears to be working right, I already did that in my testing instance of Ren'Py and couldn't find issues.Regardless, just because I don't find bugs, doesn't mean they aren't there. I may just be testing it wrong.
Resolves #6898