← Back to team overview

instant team mailing list archive

Re: About signature and hash

 

On Mon, Sep 01, 2008 at 06:43:34PM +0200, Martin Sandve Alnæs wrote:
> Actually, since the hash code of an object isn't required to be
> unique, hash(signature) and signature.__eq__ is good enough for
> in-memory cache, but not for disk cache. If Instant takes a
> user-defined signature to be used with the disk cache, it must be a
> unique string since it's used in filenames.
> 
> Technically, md5 sums aren't unique either, but it's probably much
> safer than "any hash code".

Yes, we need to cache on both the object (in memory) and the signature
(on disk).

We could have something like the following (in a form compiler):

  def jit(form):

      # Check module cache for object
      module = instant.get_module(object=form)
      if not module is None:
          return module

      # Check module cache for signature
      signature = form.signature()
      module = instant.get_module(signature=signature)
      if not module is None:
          return module

      # Generate code and build module
      code = compile(form)
      return instant.build_module(code)

-- 
Anders

Attachment: signature.asc
Description: Digital signature


References