List Info

Thread: More Django optimization




More Django optimization
user name
2007-12-24 16:17:05
I suggest using python 2.5 standard library
functools.partial when it
is available instead of django.utils.functional.curry. This
functions
are technically the same with the exception that partial is
written in
C and is about 2 times faster.

Just replace every:
from django.utils.functional import curry

with
try:
    from functools import partial as curry
except ImportError: #Python 2.3 and 2.4 fallback
    from django.utils.functional import curry

Note that benchmarks in previous post was *without* that
change.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django developers" group.
To post to this group, send email to django-developersgooglegroups.com
To unsubscribe from this group, send email to
django-developers-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en

-~----------~----~----~----~------~----~------~--~---


Re: More Django optimization
user name
2007-12-24 17:24:30
Sadly, it cannot be used out of the box, partial objects
don't work
with dispatcher and some unit test failed when I tried to
use it in
models.base. But it could be integrated slowly.

On 25 ΔΕΛ, 01:17, Ivan Illarionov <ivan.illario...gmail.com> wrote:
> I suggest using python 2.5 standard library
functools.partial when it
> is available instead of django.utils.functional.curry.
This functions
> are technically the same with the exception that
partial is written in
> C and is about 2 times faster.
>
> Just replace every:
> from django.utils.functional import curry
>
> with
> try:
>     from functools import partial as curry
> except ImportError: #Python 2.3 and 2.4 fallback
>     from django.utils.functional import curry
>
> Note that benchmarks in previous post was *without*
that change.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django developers" group.
To post to this group, send email to django-developersgooglegroups.com
To unsubscribe from this group, send email to
django-developers-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en

-~----------~----~----~----~------~----~------~--~---


Re: More Django optimization
user name
2007-12-24 17:34:19
On Dec 24, 2007 4:17 PM, Ivan Illarionov
<ivan.illarionovgmail.com> wrote:
>
> I suggest using python 2.5 standard library
functools.partial when it
> is available instead of django.utils.functional.curry.
This functions
> are technically the same with the exception that
partial is written in
> C and is about 2 times faster.
>
> Just replace every:
> from django.utils.functional import curry
>
> with
> try:
>     from functools import partial as curry
> except ImportError: #Python 2.3 and 2.4 fallback
>     from django.utils.functional import curry
>
> Note that benchmarks in previous post was *without*
that change.

I'm not sure why, but the objects returned by
functools.curry can't be
inspected and are simply not normal python callables.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django developers" group.
To post to this group, send email to django-developersgooglegroups.com
To unsubscribe from this group, send email to
django-developers-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en

-~----------~----~----~----~------~----~------~--~---


Re: More Django optimization
user name
2007-12-25 03:49:39
I think this is because functools.partial is written as C
extension.
You can't get the code object from them for inspection. But
you still
can call them, get/set custom attributes, get the curried
function as
func attribute, get curried args from args attribute and
curried
keyword arguments from keywords attribute. So they still can
be
inspected but in different way. The cost of speed.

On 25 ΔΕΛ, 02:34, "Jeremy Dunck" <jdu...gmail.com> wrote:
> On Dec 24, 2007 4:17 PM, Ivan Illarionov
<ivan.illario...gmail.com> wrote:
>
>
>
>
>
> > I suggest using python 2.5 standard library
functools.partial when it
> > is available instead of
django.utils.functional.curry. This functions
> > are technically the same with the exception that
partial is written in
> > C and is about 2 times faster.
>
> > Just replace every:
> > from django.utils.functional import curry
>
> > with
> > try:
> >     from functools import partial as curry
> > except ImportError: #Python 2.3 and 2.4 fallback
> >     from django.utils.functional import curry
>
> > Note that benchmarks in previous post was
*without* that change.
>
> I'm not sure why, but the objects returned by
functools.curry can't be
> inspected and are simply not normal python callables.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django developers" group.
To post to this group, send email to django-developersgooglegroups.com
To unsubscribe from this group, send email to
django-developers-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en

-~----------~----~----~----~------~----~------~--~---


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )