Re: Inner imports in core code

2008-09-24 Thread Ludvig Ericson
On Sep 24, 2008, at 18:27, Alex Myodov wrote: > Being curious, had tried several benchmarks as well. > Indeed, the function-level imports have some overhead. But the > overhead becomes less and less important, as long as the function > complexity increases. If a function does nothing except import

Re: Inner imports in core code

2008-09-24 Thread Alex Myodov
Being curious, had tried several benchmarks as well. Indeed, the function-level imports have some overhead. But the overhead becomes less and less important, as long as the function complexity increases. If a function does nothing except import (as in your case), the performance hit is several hun

Re: Inner imports in core code

2008-09-24 Thread Ludvig Ericson
On Sep 24, 2008, at 14:52, Simon Willison wrote: > Not entirely sure how I managed to miss your benchmark figures when I > read your mail, but I'm wrong here - there's clearly a performance > overhead involved in importing inside a function. It would be > interesting to see how much this affects D

Re: Inner imports in core code

2008-09-24 Thread Simon Willison
On Sep 24, 1:40 pm, Simon Willison <[EMAIL PROTECTED]> wrote: > As a result the performance overhead from having imports inside > functions as opposed to at module level should be virtually non- > existent. Not entirely sure how I managed to miss your benchmark figures when I read your mail, but

Re: Inner imports in core code

2008-09-24 Thread Simon Willison
On Sep 24, 8:37 am, David Cramer <[EMAIL PROTECTED]> wrote: > I was digging through some code today, and I noticed imports are > happening within a lot of functions. It was my knowledge that it works > like so: > > import in a function is the same as ruby's load or php's include -- > its executed

Re: Inner imports in core code

2008-09-24 Thread Jeremy Dunck
Note that in some cases, dynamic imports are done to avoid loading a Django subsystem, large external library, or optional dependency until it is strictly necessary. There are certainly still examples where none of those good reasons apply. On Sep 24, 2008, at 2:37 AM, David Cramer <[EMAIL

Inner imports in core code

2008-09-24 Thread David Cramer
I was digging through some code today, and I noticed imports are happening within a lot of functions. It was my knowledge that it works like so: import in a function is the same as ruby's load or php's include -- its executed everytime the function is import in a module outside a function is lik