[Scons-users] AddPostAction memoization problem
Mats Wichmann
mats at wichmann.us
Wed May 29 17:41:29 EDT 2024
On 5/29/24 15:27, Mike Haboustak wrote:
> On Wed, May 29, 2024 at 9:49 AM Mats Wichmann <mats at wichmann.us> wrote:
>>
>> I'd personally agree as to correct behavior: if a step that makes
>> changes has completed, information related to the node should be up to
>> date and not old. I guess it's worth mentioning that the getsize()
>> method isn't *officially* exposed as a public interface, it's possible
>> there was an actual reason for that back in the mists of time.
>>
>
> Is it true that a function isn't officially exposed if it doesn't have
> a docstring in the API docs? The documentation includes
> SCons.Node.FS.File.get_size() right next to get_relpath().
> https://scons.org/doc/latest/HTML/scons-api/SCons.Node/#SCons.Node.FS.File.get_size
No, the "public API" is the manpage. Unfortunately, the "API Docs"
don't distinguish between public and internal reliably (we eventually
added that notation to the main page). Every so often there's a
docstring annotation to help out, but it's not frequent.
>
>> It should be sufficient to just remove the memoized 'stat', since it's
>> the thing that holds information SCons itself doesn't update - it
>> eventually comes from an os.stat() call - that could be considered
>> "expensive" and thus worth memoizing.
>
> I think exists() and rexists() need to be cleared as well. The
> get_size() call returns -1 because the file didn't exist when the
> Builder was executed. It never tries to get the current value
> rfile().getsize()
The size obtained by get_size is memoized, so it maybe needs to be
cleared too. I'm not sure why we need two such similarly named node
methods (get_size is for File nodes only, and as you say, accounts for a
repository). Let's just say some docstrings or comments here would have
been cool, for those of us who haven't been working on SCons for 20+
years.... :-)
>> Stepping aside from the internal implementation questions, you could in
>> this particular case do something that sidesteps the memoized stat
>> structure, like:
>>
>> print("PostAction:", os.path.getsize(target[0].abspath))
>
> This does work, and it's the same work-around we implemented. I was
> just trying to use the SCons object model and API functions as much as
> possible.
Yeah, I get it.
More information about the Scons-users
mailing list