Subject: [Instant-dev] md5 deprecated

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 13:01:11 +0200

Instant should use this instead of md5:
http://www.python.org/doc/current/lib/module-hashlib.html

-- 
Martin

---

From: Ilmar Wilbers <[email-masked]>
Date: Mon, 01 Sep 2008 13:03:29 +0200

I'll put it on the todo list.

ilmar

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 13:07:33 +0200

Another suggestion for the TODO list (but not on the top!):
- Implement in-memory cache for already imported modules (based on signature)
  I.e. a global dict on the form
  _module_cache = { "module signature": previously_compiled_module }
  which is looked up transparently.

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 1 Sep 2008 13:42:27 +0200

>   which is looked up transparently.

It should not need to be mapped specifically from a signature, but
should work for everything that is hashable (which means we can just
use a dictionary).

FFC keeps a module cache based on the form object (since computing the
signature may sometimes take time).

-- 
Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 13:54:09 +0200

> signature may sometimes take time).

Computing repr(form) + repr(options) shouldn't take much time?
Anyway, the signature in question here may be a signature passed
by the user (e.g. FFC), i.e. it can be a hash string of anything you want.

--
Martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 1 Sep 2008 14:00:23 +0200

> Computing repr(form) + repr(options) shouldn't take much time?

Yes, it does. At least it is noticeable for some forms.

> by the user (e.g. FFC), i.e. it can be a hash string of anything you want.

Does it have to be a string? I'm just saying Instant doesn't need to
know what it is, as long as it's hashable.

-- 
Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 14:09:45 +0200

> know what it is, as long as it's hashable.

Ok.

-- 
Martin

---

From: Kent-Andre Mardal <[email-masked]>
Date: Mon, 01 Sep 2008 15:16:59 +0200

> Ok.

So the cache should be: 

module_cache [hash(whatever)] = whatever 

where whatever might be a signature or something different ?  

Kent

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 15:21:55 +0200

> where whatever might be a signature or something different ?

Almost:

module_cache [hash(whatever)] = module_compiled_with_given_whatever_id_object

whatever can e.g. be the UFL form, which instant doesn't know how
relates to the code.

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Mon, 1 Sep 2008 15:24:11 +0200

> whatever can e.g. be the UFL form, which instant doesn't know how

It should be enough to do

  module_cache[whatever] = module_compiled_with_given_whatever_id_object

-- 
Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Mon, 1 Sep 2008 15:38:47 +0200

>  module_cache[whatever] = module_compiled_with_given_whatever_id_object

Of course. The dict calls hash itself. But whatever must support == as
well, not only hash.

--
Martin