>Chris Angelico wrote:
[snippage]
>> def func(x):
>>len = len # localize len
>>for i in x:
>>len(i) # use it exactly as you otherwise would
In article <4e39a6b5$0$29973$c3e8da3$54964...@news.astraweb.com>
Steven D'Aprano wrote:
>That can't work. The problem is that because len
On Wed, Aug 3, 2011 at 8:51 PM, Steven D'Aprano
wrote:
> Chris Angelico wrote:
>
>> Ah! I was not aware of this, and thought that locals were a dictionary
>> too. Of course, it makes a lot of sense. In that case, the classic
>> "grab it as a local" isn't just loading down the locals dictionary
>>
Chris Angelico writes:
[...]
> The only actual data I have on the subject is the perfect-numbers
> search the other day; Pike managed the same task in a fraction of the
> time that Python spent on it. Pike has a single integer type that
> quietly switches from small to large at 2**32, with a noti
Chris Angelico wrote:
>> In CPython at least, local lookups are faster
>> than globals: locals are stored in a fixed array, and the function knows
>> the numeric offset of each variable.
>
> Ah! I was not aware of this, and thought that locals were a dictionary
> too. Of course, it makes a lot of
Thomas Jollans, 03.08.2011 12:00:
JavaScript JITs are smart enough, so a good Python
JIT could be as well.
Why "could"? There's PyPy if you need it.
Stefan
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 3, 2011 at 11:16 AM, Steven D'Aprano
wrote:
> Chris Angelico wrote:
>> Of course; that's a different issue altogether. No, I'm talking about
>> the way a tight loop will involve repeated lookups for the same name.
>
> It's not really a different issue. The "standard" approach for perfo
Chris Angelico wrote:
> On Tue, Aug 2, 2011 at 9:23 PM, Terry Reedy wrote:
>> On 8/2/2011 12:55 PM, Chris Angelico wrote:
>>>
>>> As I understand it, Python exclusively late-binds names; when you
>>> define a function, nothing is ever pre-bound.
>>
>> By 'pre-bound' you presumably mean bound at d
On 03/08/11 00:08, Chris Angelico wrote:
> With the local-variable-snapshot technique ("len = len"), can anything
> be optimized, since the parser can guarantee that nothing ever
> reassigns to it? If not, perhaps this would be a place where something
> might be implemented:
> [...]
Yes, it can. T
Chris Angelico, 03.08.2011 00:08:
So... Would this potentially produce wrong results? Would it be of any
use, or would its benefit be only valued in times when the whole
function needs to be redone in C?
Note that, in most cases, you do not need to "redo the whole function in
C". You can just
On Wed, Aug 3, 2011 at 5:46 AM, Dennis Lee Bieber wrote:
> Horrors... That looks like some MUF code I've seen (I never had a
> MUF flag on my old characters, so had no privilege to write in MUF --
> MPI was available to all, and even it had some links to MUF operations
> using similar magic
On 08/03/2011 12:26 AM, Chris Angelico wrote:
> On Tue, Aug 2, 2011 at 11:21 PM, Gelonida N wrote:
>> On the other hand: It might be interesting, that the early binding would
>> just take place when python is invoked with -O
>>
>
> This could be an excellent safety catch, but on the other hand, i
On 08/03/2011 12:26 AM, Chris Angelico wrote:
> On Tue, Aug 2, 2011 at 11:21 PM, Gelonida N wrote:
>> On the other hand: It might be interesting, that the early binding would
>> just take place when python is invoked with -O
>>
>
> This could be an excellent safety catch, but on the other hand, i
On Tue, Aug 2, 2011 at 11:21 PM, Gelonida N wrote:
> On the other hand: It might be interesting, that the early binding would
> just take place when python is invoked with -O
>
This could be an excellent safety catch, but on the other hand, it
might destroy all value of the feature - once again,
On 08/03/2011 12:08 AM, Chris Angelico wrote:
> With the local-variable-snapshot technique ("len = len"), can anything
> be optimized, since the parser can guarantee that nothing ever
> reassigns to it? If not, perhaps this would be a place where something
> might be implemented:
>
> @const(len,ma
On Tue, Aug 2, 2011 at 9:23 PM, Terry Reedy wrote:
> On 8/2/2011 12:55 PM, Chris Angelico wrote:
>>
>> As I understand it, Python exclusively late-binds names; when you
>> define a function, nothing is ever pre-bound.
>
> By 'pre-bound' you presumably mean bound at definition time rather than call
On 8/2/2011 12:55 PM, Chris Angelico wrote:
As I understand it, Python exclusively late-binds names; when you
define a function, nothing is ever pre-bound.
By 'pre-bound' you presumably mean bound at definition time rather than
call time. Default arg objects *are* pre-computed and pre-bound to
* 2011-08-02T11:03:24-07:00 * Chris Rebert wrote:
> Smart enough JITers can infer that late binding is not being exploited
> for certain variables and thus optimize them accordingly. Look how
> fast some of the JavaScript VMs are, despite JavaScript also being
> highly dynamic.
Or Common Lisp. It
Chris Angelico writes:
> As I understand it, Python exclusively late-binds names; when you
> define a function, nothing is ever pre-bound. This allows a huge
> amount of flexibility (letting you "reach into" someone else's
> function and change its behaviour), but it's flexibility that most
> pro
On 02/08/11 19:42, Chris Angelico wrote:
> On Tue, Aug 2, 2011 at 6:18 PM, Thomas Jollans wrote:
>> I suppose it would be possible to introduce a kind of "constant
>> globals" namespace that a JIT compiler could then use to optimise, but
>> how much would this help?
>
> Surely it must help a lot;
On Tue, Aug 2, 2011 at 9:55 AM, Chris Angelico wrote:
> As I understand it, Python exclusively late-binds names; when you
> define a function, nothing is ever pre-bound. This allows a huge
> amount of flexibility (letting you "reach into" someone else's
> function and change its behaviour), but it
On Tue, Aug 2, 2011 at 6:18 PM, Thomas Jollans wrote:
> I suppose it would be possible to introduce a kind of "constant
> globals" namespace that a JIT compiler could then use to optimise, but
> how much would this help?
Surely it must help a lot; looking up names is string operations. If
"len" c
On 02/08/11 18:55, Chris Angelico wrote:
> As I understand it, Python exclusively late-binds names; when you
> define a function, nothing is ever pre-bound. This allows a huge
> amount of flexibility (letting you "reach into" someone else's
> function and change its behaviour), but it's flexibility
As I understand it, Python exclusively late-binds names; when you
define a function, nothing is ever pre-bound. This allows a huge
amount of flexibility (letting you "reach into" someone else's
function and change its behaviour), but it's flexibility that most
programs use seldom if at all.
First
23 matches
Mail list logo