On Thu, 2006-09-07 at 13:28 -0500, Adrian Holovaty wrote:
> On 9/7/06, Michael Spencer <[EMAIL PROTECTED]> wrote:
> > Martin's version is indeed faster, but has a 'gotcha' in that it precludes
> > passing a keyword arguments named 'fct' to a curried function...
> > [...]
> > Better to rename fct to something less likely to clash, such as _curried_fct
> 
> Good call, Michael. I've renamed the parameter to '_curried_func' in
> changeset 3735.
> 
> > If you're really hunting for speed, there is a significant boost available 
> > in
> > the common special case of a python function curried with one positional
> > argument.  In this case, you can [ab]use the method binding machinery, e.g.:
> > [...]
> > This is about twice as fast as curry2 for the case of a python function 
> > curried
> > with one argument. It also offers better introspection than either curry1 or
> > curry2, since the original signature is preserved.  It's a bigger change 
> > than
> > the curry2 though, since it changes the type of the curry from function to 
> > bound
> > method.
> 
> I was with you until "it changes the type of the curry from function
> to bound method." How does it do that?
> 
> Adrian

I think what's going on is that in the try : except clause, the return
value is the actual bound method, retrieved using the __get__
magic-method.

And it doesn't work very well that way either. I've tried Michael's
method and the whole house comes tumbling down. See traceback below when
trying to load a flatpage.

3735 works pretty well.

/Marc DM


traceback :

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in 
HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", 
line 163, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", 
line 140, in __call__
    response = middleware_method(request, response)

  File 
"/usr/lib/python2.4/site-packages/django/contrib/flatpages/middleware.py", line 
10, in process_response
    return flatpage(request, request.path)

  File "/usr/lib/python2.4/site-packages/django/contrib/flatpages/views.py", 
line 23, in flatpage
    f = get_object_or_404(FlatPage, url__exact=url, 
sites__id__exact=settings.SITE_ID)

  File "/usr/lib/python2.4/site-packages/django/shortcuts/__init__.py", line 
15, in get_object_or_404
    return klass._default_manager.get(*args, **kwargs)

  File "/usr/lib/python2.4/site-packages/django/db/models/manager.py", line 67, 
in get
    return self.get_query_set().get(*args, **kwargs)

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 211, 
in get
    obj_list = list(clone)

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 103, 
in __iter__
    return iter(self._get_data())

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 430, 
in _get_data
    self._result_cache = list(self.iterator())

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 171, 
in iterator
    select, sql, params = self._get_sql_clause()

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 444, 
in _get_sql_clause
    joins2, where2, params2 = self._filters.get_sql(opts)

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 574, 
in get_sql
    joins2, where2, params2 = val.get_sql(opts)

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 622, 
in get_sql
    return parse_lookup(self.kwargs.items(), opts)

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 734, 
in parse_lookup
    joins2, where2, params2 = lookup_inner(path, lookup_type, value, opts, 
opts.db_table, None)

  File "/usr/lib/python2.4/site-packages/django/db/models/query.py", line 785, 
in lookup_inner
    intermediate_table = field.m2m_db_table()

TypeError: _get_m2m_db_table() takes exactly 2 arguments (1 given)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to