Re: Django Model Inheritance

2007-12-19 Thread ivan.illarionov

1. You still can use super in NonDeleted.get_query_set by using
self.__class__ instead of NonDeleted
2. It could be better to use issubclass(key, models.Manager) instead
of key == 'objects'

On 19 дек, 11:53, Sridhar Ratnakumar <[EMAIL PROTECTED]> wrote:
> I wanted to share this little hack of mine - conceptual (not database-
> based) inheritance for 
> django:http://nearfar.org/blog/django-model-inheritance.html
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: signals

2007-12-23 Thread ivan.illarionov

As I know PyDispatcher project has evolved into Louie project and is
actively maintained by the same author. The code is *not* ugly, is
closer to Django coding style and has a lot of improvements.
http://louie.berlios.de/

Even more, I replaced content of django.dispatch with louie code,
renamed all imports `from louie` to `from django.dispatch` and
everything worked without any errors.

Hope this information will help.

Ivan Illarionov
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: signals

2007-12-23 Thread ivan.illarionov

Just did a simple benchmark and found that Louie is about 150% slower
than current dispatcher in Django. It looks like Louie developers
doesn't care about performance at all...

On 23 дек, 16:49, Simon Willison <[EMAIL PROTECTED]> wrote:
> On 23 Dec 2007, at 12:39, ivan.illarionov wrote:
>
> > As I know PyDispatcher project has evolved into Louie project and is
> > actively maintained by the same author. The code is *not* ugly, is
> > closer to Django coding style and has a lot of improvements.
> >http://louie.berlios.de/
>
> > Even more, I replaced content of django.dispatch with louie code,
> > renamed all imports `from louie` to `from django.dispatch` and
> > everything worked without any errors.
>
> Have you benchmarked Louie compared to PyDispatcher at all? From
> looking over their documentation they don't seem to have made any
> changes that would result in a substantial speed increase.
>
> Cheers,
>
> Simon Willison
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Model Creation Optimization

2007-12-24 Thread ivan.illarionov

Please take a look at my patch at http://code.djangoproject.com/ticket/6214
There's no need to check for _meta
if base is not Model and issubclass(base, Model)

All Model subclasses except Model class itself have _meta attribute.

It can be optimized further if we build the list of parents in the
beginning of __new__ where a Model subclass check already exists and
Model class will raise NameError


On 24 дек, 12:05, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Mon, 2007-12-24 at 00:37 -0800, David Cramer wrote:
> > Any reason it's not the default?
>
> It might not always be available, was one concern (although I suspect
> not a real problem). The other one is that if you're running your
> application's tests, you should be using the same encoding that your
> production database is using, which might not be UTF-8.
>
> Malcolm
>
> --
> Atheism is a non-prophet organization.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Model Creation Optimization

2007-12-24 Thread ivan.illarionov

Just benchmarked my patch. Class creation runs faster. 1000 simple
classes was created in 2.5 seconds vs. 2.7 seconds and 1000 subclasses
in 2.6 vs. 2.8

On 24 дек, 20:59, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
> Please take a look at my patch athttp://code.djangoproject.com/ticket/6214
> There's no need to check for _meta
> if base is not Model and issubclass(base, Model)
>
> All Model subclasses except Model class itself have _meta attribute.
>
> It can be optimized further if we build the list of parents in the
> beginning of __new__ where a Model subclass check already exists and
> Model class will raise NameError
>
> On 24 дек, 12:05, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > On Mon, 2007-12-24 at 00:37 -0800, David Cramer wrote:
> > > Any reason it's not the default?
>
> > It might not always be available, was one concern (although I suspect
> > not a real problem). The other one is that if you're running your
> > application's tests, you should be using the same encoding that your
> > production database is using, which might not be UTF-8.
>
> > Malcolm
>
> > --
> > Atheism is a non-prophet organization.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Model Creation Optimization

2007-12-24 Thread ivan.illarionov

My patch is little faster against hasattr() 2.54 vs 2.56 and 2.56 vs
2.59

On 24 дек, 22:04, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
> Just benchmarked my patch. Class creation runs faster. 1000 simple
> classes was created in 2.5 seconds vs. 2.7 seconds and 1000 subclasses
> in 2.6 vs. 2.8
>
> On 24 дек, 20:59, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
>
> > Please take a look at my patch athttp://code.djangoproject.com/ticket/6214
> > There's no need to check for _meta
> > if base is not Model and issubclass(base, Model)
>
> > All Model subclasses except Model class itself have _meta attribute.
>
> > It can be optimized further if we build the list of parents in the
> > beginning of __new__ where a Model subclass check already exists and
> > Model class will raise NameError
>
> > On 24 дек, 12:05, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > > On Mon, 2007-12-24 at 00:37 -0800, David Cramer wrote:
> > > > Any reason it's not the default?
>
> > > It might not always be available, was one concern (although I suspect
> > > not a real problem). The other one is that if you're running your
> > > application's tests, you should be using the same encoding that your
> > > production database is using, which might not be UTF-8.
>
> > > Malcolm
>
> > > --
> > > Atheism is a non-prophet organization.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Model Creation Optimization

2007-12-24 Thread ivan.illarionov

I was able to optimize it even more by moving classmethods of Model to
ModelBase as normal methods. It's really faster and clearer because
separates initialization of Model classes and Model instances

On 24 дек, 23:41, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
> My patch is little faster against hasattr() 2.54 vs 2.56 and 2.56 vs
> 2.59
>
> On 24 дек, 22:04, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
>
> > Just benchmarked my patch. Class creation runs faster. 1000 simple
> > classes was created in 2.5 seconds vs. 2.7 seconds and 1000 subclasses
> > in 2.6 vs. 2.8
>
> > On 24 дек, 20:59, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
>
> > > Please take a look at my patch athttp://code.djangoproject.com/ticket/6214
> > > There's no need to check for _meta
> > > if base is not Model and issubclass(base, Model)
>
> > > All Model subclasses except Model class itself have _meta attribute.
>
> > > It can be optimized further if we build the list of parents in the
> > > beginning of __new__ where a Model subclass check already exists and
> > > Model class will raise NameError
>
> > > On 24 дек, 12:05, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > > > On Mon, 2007-12-24 at 00:37 -0800, David Cramer wrote:
> > > > > Any reason it's not the default?
>
> > > > It might not always be available, was one concern (although I suspect
> > > > not a real problem). The other one is that if you're running your
> > > > application's tests, you should be using the same encoding that your
> > > > production database is using, which might not be UTF-8.
>
> > > > Malcolm
>
> > > > --
> > > > Atheism is a non-prophet organization.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Model Creation Optimization

2007-12-24 Thread ivan.illarionov

All tests passed. Very simple benchmarks show speed increase of about
0.04-0.07 seconds per 1000 model classes compared to hasattr() version
and about 0.15 seconds per 1000 model classes compared to dir(base). I
know it is not dramatically faster but it *is* faster (and IMHO
clearer and more DRY). Logic tells me that those changes can effect
speeds only in positive way.

On 25 дек, 00:19, Aaron Krill <[EMAIL PROTECTED]>
wrote:
> Please make sure these changes do not cause any unit test failures.
> Also, benchmarks!!! :-) How much of a speed difference is there thanks
> to these latest changes you've made to ModelBase? And you may want to
> run benchmarks and ensure its not effecting speeds adversely
> elsewhere.
>
> On Dec 24, 1:08 pm, "ivan.illarionov" <[EMAIL PROTECTED]>
> wrote:
>
> > I was able to optimize it even more by moving classmethods of Model to
> > ModelBase as normal methods. It's really faster and clearer because
> > separates initialization of Model classes and Model instances
>
> > On 24 дек, 23:41, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
>
> > > My patch is little faster against hasattr() 2.54 vs 2.56 and 2.56 vs
> > > 2.59
>
> > > On 24 дек, 22:04, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
>
> > > > Just benchmarked my patch. Class creation runs faster. 1000 simple
> > > > classes was created in 2.5 seconds vs. 2.7 seconds and 1000 subclasses
> > > > in 2.6 vs. 2.8
>
> > > > On 24 дек, 20:59, "ivan.illarionov" <[EMAIL PROTECTED]> wrote:
>
> > > > > Please take a look at my patch 
> > > > > athttp://code.djangoproject.com/ticket/6214
> > > > > There's no need to check for _meta
> > > > > if base is not Model and issubclass(base, Model)
>
> > > > > All Model subclasses except Model class itself have _meta attribute.
>
> > > > > It can be optimized further if we build the list of parents in the
> > > > > beginning of __new__ where a Model subclass check already exists and
> > > > > Model class will raise NameError
>
> > > > > On 24 дек, 12:05, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > > > > > On Mon, 2007-12-24 at 00:37 -0800, David Cramer wrote:
> > > > > > > Any reason it's not the default?
>
> > > > > > It might not always be available, was one concern (although I 
> > > > > > suspect
> > > > > > not a real problem). The other one is that if you're running your
> > > > > > application's tests, you should be using the same encoding that your
> > > > > > production database is using, which might not be UTF-8.
>
> > > > > > Malcolm
>
> > > > > > --
> > > > > > Atheism is a non-prophet 
> > > > > > organization.http://www.pointy-stick.com/blog/
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---