Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Sidnei da Silva
On Wed, Jul 05, 2006 at 11:30:19PM +0200, [EMAIL PROTECTED] wrote:
| Sidnei da Silva wrote at 2006-7-5 18:06 -0300:
| >...and then I find it. Phew :)
| >
| >  http://article.gmane.org/gmane.comp.web.zope.devel/8925
| 
| But you see that this post does not compare local versus global
| access but "cell reference in enclosing (!) scope" versus global access.
| 
| As my example proves, "local access" (i.e. "cell reference in local scope")
| *IS* faster than global access.

Yup Yup.

-- 
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread dieter
Sidnei da Silva wrote at 2006-7-5 18:06 -0300:
>...and then I find it. Phew :)
>
>  http://article.gmane.org/gmane.comp.web.zope.devel/8925

But you see that this post does not compare local versus global
access but "cell reference in enclosing (!) scope" versus global access.

As my example proves, "local access" (i.e. "cell reference in local scope")
*IS* faster than global access.

>-- 
>Sidnei da Silva
>Enfold Systemshttp://enfoldsystems.com
>Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214

-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Sidnei da Silva
...and then I find it. Phew :)

  http://article.gmane.org/gmane.comp.web.zope.devel/8925
-- 
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Sidnei da Silva
On Wed, Jul 05, 2006 at 10:29:34PM +0200, [EMAIL PROTECTED] wrote:
| That would extremely surprise me:
| 
|   While global lookup was significantly optimized,
|   it is still an lookup with a string as argument.
| 
|   For local lookup on the other hand, the compiler has
|   turned the name into an index and at runtime, an
|   indexed access it made. That is still faster.

Hum. Hum. Wonder where my brain is. I wish I could find the email with
the benchmarks to make me look less silly.

-- 
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread dieter
Florent Guillaume wrote at 2006-7-5 18:56 +0200:
>Is anyone opposed to me removing the stupid:
> _getattr = getattr
> _none = None
> marker = _marker
>local namespace """optimizations""" that are found in  
>unrestrictedTraverse?

Why do you think they were stupid?

They do save time -- although it probably does not dominate the total time.



-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread dieter
Sidnei da Silva wrote at 2006-7-5 16:45 -0300:
> ...
>It has been demonstrated in other lists that global lookups are most
>of the time faster than local lookups in recent versions of python.

That would extremely surprise me:

  While global lookup was significantly optimized,
  it is still an lookup with a string as argument.

  For local lookup on the other hand, the compiler has
  turned the name into an index and at runtime, an
  indexed access it made. That is still faster.


An a simple test shows that I am right:

>>> i = 1
>>> def f1(): # using global "i" directly
...   x=0
...   for k in xrange(100): x += i
...
>>> def f2(): # using global "i" via local "_i"
...   x=0; _i=i
...   for k in xrange(100): x += _i
...
>>> from timeit import Timer
>>> t=Timer('__main__.f1()', 'import __main__')
>>> t.timeit()
33.647971153259277
>>> t=Timer('__main__.f2()', 'import __main__')
>>> t.timeit()
28.818410873413086



I have seen timings which might be misinterpreted in the way
you described above:

def f(..., opt1=glob1):
  ...

can be slower than directly using "glob1".
The reason in this case is that handling optional arguments
costs something which might eat the savings due to local access.

>
>
>-- 
>Sidnei da Silva
>Enfold Systemshttp://enfoldsystems.com
>Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214

-- 
Dieter
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Andreas Jung



--On 5. Juli 2006 16:45:21 -0300 Sidnei da Silva <[EMAIL PROTECTED]> 
wrote:



On Wed, Jul 05, 2006 at 07:21:29PM +0200, Andreas Jung wrote:
| > Does that mean you're for or against it?
| >
|
| For (of course) :-)

It has been demonstrated in other lists that global lookups are most
of the time faster than local lookups in recent versions of python.




I am *for* removing them. These culprits must go.

-aj

pgpeyj44eLSBa.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Sidnei da Silva
On Wed, Jul 05, 2006 at 07:21:29PM +0200, Andreas Jung wrote:
| >Does that mean you're for or against it?
| >
| 
| For (of course) :-)

It has been demonstrated in other lists that global lookups are most
of the time faster than local lookups in recent versions of python.


-- 
Sidnei da Silva
Enfold Systemshttp://enfoldsystems.com
Fax +1 832 201 8856 Office +1 713 942 2377 Ext 214


signature.asc
Description: Digital signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Andreas Jung



--On 5. Juli 2006 19:00:52 +0100 Tim Hicks <[EMAIL PROTECTED]> wrote:


Florent Guillaume wrote:

Is anyone opposed to me removing the stupid:
_getattr = getattr
_none = None
marker = _marker
local namespace """optimizations""" that are found in
unrestrictedTraverse?


I find these things rather confusing when looking at zope core code, and
always wondered why they were there.  In what sense are they
optimisations?


Evil tricks from the ancient Zope world. Such lookups were faster because 
the items were directly found in the local namespace so one saved time 
looking them up in the global namespace.


-aj



pgprvSImjP47F.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Tim Hicks

Florent Guillaume wrote:

Is anyone opposed to me removing the stupid:
_getattr = getattr
_none = None
marker = _marker
local namespace """optimizations""" that are found in unrestrictedTraverse?


I find these things rather confusing when looking at zope core code, and 
always wondered why they were there.  In what sense are they optimisations?



Tim
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Andreas Jung



--On 5. Juli 2006 19:11:16 +0200 Florent Guillaume <[EMAIL PROTECTED]> wrote:


On 5 Jul 2006, at 19:05, Andreas Jung wrote:

--On 5. Juli 2006 18:56:25 +0200 Florent Guillaume <[EMAIL PROTECTED]>
wrote:


Is anyone opposed to me removing the stupid:
 _getattr = getattr
 _none = None
 marker = _marker
local namespace """optimizations""" that are found in
unrestrictedTraverse?



I am pretty sure that the complete Zope core is still full of those
optimizations.


Does that mean you're for or against it?



For (of course) :-)

-aj

pgpQrpt9LJe13.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Florent Guillaume

On 5 Jul 2006, at 19:05, Andreas Jung wrote:
--On 5. Juli 2006 18:56:25 +0200 Florent Guillaume <[EMAIL PROTECTED]>  
wrote:



Is anyone opposed to me removing the stupid:
 _getattr = getattr
 _none = None
 marker = _marker
local namespace """optimizations""" that are found in
unrestrictedTraverse?



I am pretty sure that the complete Zope core is still full of those
optimizations.


Does that mean you're for or against it?

Florent

--
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]



___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )


Re: [Zope-dev] local namespace optimizations?

2006-07-05 Thread Andreas Jung



--On 5. Juli 2006 18:56:25 +0200 Florent Guillaume <[EMAIL PROTECTED]> wrote:


Is anyone opposed to me removing the stupid:
 _getattr = getattr
 _none = None
 marker = _marker
local namespace """optimizations""" that are found in
unrestrictedTraverse?



I am pretty sure that the complete Zope core is still full of those
optimizations.

-aj

pgpnm0umtEDo2.pgp
Description: PGP signature
___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )


[Zope-dev] local namespace optimizations?

2006-07-05 Thread Florent Guillaume

Is anyone opposed to me removing the stupid:
_getattr = getattr
_none = None
marker = _marker
local namespace """optimizations""" that are found in  
unrestrictedTraverse?


Florent

--
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   [EMAIL PROTECTED]



___
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
http://mail.zope.org/mailman/listinfo/zope-announce

http://mail.zope.org/mailman/listinfo/zope )