google-code-export / marinemap

Automatically exported from code.google.com/p/marinemap
Other
1 stars 2 forks source link

Feature get_options classmethod calls FeatureOptions.__init__ #475

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Not sure the best way around this but currently, to get the options for a 
Feature class, a new FeatureOptions(klass) is instantiated each time. It's not 
necessarily harmful but there is a lot of validation/checking that happens on 
FeatureOptions.__init__ that is not necessary each time. Migght be a 
performance hit or at the very least a lot of unnecessary debug log output.

Maybe cache the results or make it a singleton property or something? 

Related: is there any way to move from the get_foo() methods to a .foo 
property? I don't know if there is a way to do @classproperty??

Original issue reported on code.google.com by perrygeo...@gmail.com on 27 Jan 2011 at 5:35

GoogleCodeExporter commented 9 years ago
Solved by changing the Feature.get_options() classmethod to read from a cached 
lingcod.features.registered_model_options list instead of re__init__ the 
FeatureOptions each time. 

On the features tests, this lead to a modest 10-15% speed up but I suspect it 
would be even greater once the number of features starts to climb. 
Feature.get_options gets called A LOT (try putting a debug logger in the 
get_options() method!) and anything we can do to optimize this will be highly 
beneficial in the long run.

Original comment by perrygeo...@gmail.com on 4 Feb 2011 at 6:05

GoogleCodeExporter commented 9 years ago
Good catch. For some reason I was under the impression this was only called 
once each time a wsgi thread (is that the right term?) was booted. 

Original comment by underbluewaters on 4 Feb 2011 at 6:38