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 practi
On Fri, Feb 11, 2011 at 11:18 AM, Santiago Caracol
wrote:
> There is no point in storing the regex strings in a pickle field. I
> already have the regex strings in ordinary django fields. What I want
> to store is *compiled* regular expressions in order to be able to use
> them without having to c
On Fri, Feb 11, 2011 at 4:18 PM, Santiago Caracol
wrote:
>> Since the pickled value is a string, it should work in fixtures.
>
> There is no point in storing the regex strings in a pickle field. I
> already have the regex strings in ordinary django fields. What I want
> to store is *compiled* regu
You're forgetting the pickle part. That's what the getter and setter
are for in my previous description.
import re
import pickle
pattern = re.compile(r'^\w{3}\s+\d{3}')
x = pickle.dumps(pattern)
type(x)
If you store 'x' in your database you won't have any difficulty with fixtures.
Shawn
--
> Since the pickled value is a string, it should work in fixtures.
There is no point in storing the regex strings in a pickle field. I
already have the regex strings in ordinary django fields. What I want
to store is *compiled* regular expressions in order to be able to use
them without having to
The picklefield stores strings. So when you say "regexes can't be
stored in fixtures," it implies that you're dealing with something
other than strings at that point. Have you tried the pickle field? As
I understand it, it's equivalent to this manual process:
Create a normal text field.
> http://pypi.python.org/pypi/django-picklefield/0.1
Thanks for the tip. This works, but it has one great disadvantage: The
regexes can't be stored in fixtures. They are stored in the database
directly. So it seems I would have to insert all my several thousand
products manually again. And if I ch
On Fri, Feb 11, 2011 at 9:47 AM, Santiago Caracol
wrote:
> Hello,
>
> I have got objects with very large regular expressions:
>
> class Product(models.Model):
> # ...
> canonical_name = models.CharField(max_length=200)
> spelling_variants = models.CharField(max_length=1, blank=True)
>
Hello,
I have got objects with very large regular expressions:
class Product(models.Model):
# ...
canonical_name = models.CharField(max_length=200)
spelling_variants = models.CharField(max_length=1, blank=True)
lexical_variants = models.CharField(max_length=1, blank=True)
9 matches
Mail list logo