Have you done any performance testing? From what I understand pythons re.compile caches internally, so after the first call subsequent calls will use the pre-compiled expression. Serializing the compiled expression using pickle isn't 'free', so I'm wondering how much difference there is in practice. Maybe a compromise of a normal model text field storing the regular expression string you build when the model is saved, and then a propery to simulate a read-only/don-demand the compiled version when you need it.
ie something like: class Product(models.Model): # ... canonical_name = models.CharField(max_length=200) spelling_variants = models.CharField(max_length=10000, blank=True) lexical_variants = models.CharField(max_length=10000, blank=True) excluded = models.CharField(max_length=10000, blank=True) permutations = models.CharField(max_length=1000, blank=True) re_str=models.TextField() compiled_re=property(lambda p: re.compile(p.re_str)) def save(self,*args,**kwargs): # do your regular expression string build here and store in self.re_str Although it seems to me like each variant propably belongs as a separate model, linking to your product. That way you can search on it, and add/remove variants fairly easily. To match now, you'd have to pull a bunch of products in a query and test each one. The database server isn't going to sweat a few hundred or even thousand names. class Variant(models.Model): name=models.CharField(db_index=True) product=models.ForeignKey(Product) Product.objects.filter(variant__name='oha android 1.1') -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.