Re: reload from ( was Python FAQ ... )

lance@markv.com
Thu, 18 Nov 93 9:06:07 PST

> tnb2d@henson.cs.virginia.edu writes:
> > In our Alice system (a set of python classes) whenever a 3D
> >object file is loaded from disk it is cached, so if a copy of that
> >object is requested it loads a lot faster, right? But what if you've
> >made changes to the file on disk and want to load it in with those
> >changes?
>
>
> Howabout using the usual trivial solution: when import sucks a file from
> disk, have it stash away a copy of the dev maj/min, inum, and ctime. Then on
> a subsequent request to import the same module, it could start by ignoring
> the cache, repeat the search algorithm until it gets to the file, then check
> the stat info for that file to see if it can trust the cache. This would
> take care of the general case: not only if you modify the file, but if you
> remove it and replace it with a symlink pointing elsewhere, or even remove
> it from a directory eariler on your search path, exposing something later on
> your search path.
>
> -Bennett
> bet@sbi.com

I do the same thing for my screen loading package.. I maintain a compiled
cache of screens and then when you request a screen, it quickly does a
posix.stat() call on the file to see if it has changed. I check the size
and the ctime. If the file changed, I reload and recompile the file
and then update the cache.. If the file has not changed, then all I do
is use the screen in the cache... Seems to work fine for me!

- --

Lance Ellinghouse lance@markv.com

1231 bit key fingerprint = 56 DA 31 0C 17 51 36 6A 4E D4 E0 11 D9 B8 06 0A
1024 bit key fingerprint = 66 2C 75 F2 E9 1C 32 84 3A E3 B0 5E 48 01 4C 37
You can receive my Public Key by `finger lance@markv.com`