Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 204673 Details for
Bug 276813
sys-apps/portage Performance improvement
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Adds caching to module_wrapper
cache_wrappers.patch (text/plain), 1.64 KB, created by
Marat Radchenko
on 2009-09-20 10:36:41 UTC
(
hide
)
Description:
Adds caching to module_wrapper
Filename:
MIME Type:
Creator:
Marat Radchenko
Created:
2009-09-20 10:36:41 UTC
Size:
1.64 KB
patch
obsolete
>diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py >index b7c4e9e..432f4fa 100644 >--- a/pym/portage/__init__.py >+++ b/pym/portage/__init__.py >@@ -3,7 +3,6 @@ > # Distributed under the terms of the GNU General Public License v2 > # $Id$ > >- > VERSION="$Rev$"[6:-2] + "-svn" > > # =========================================================================== >@@ -206,14 +205,24 @@ class _unicode_module_wrapper(object): > """ > Wraps a module and wraps all functions with _unicode_func_wrapper. > """ >- __slots__ = ('_mod', '_encoding', '_overrides') >+ __slots__ = ('_mod', '_encoding', '_overrides', '_cache') > >- def __init__(self, mod, encoding=_encodings['fs'], overrides=None): >+ def __init__(self, mod, encoding=_encodings['fs'], overrides=None, cache=True): > object.__setattr__(self, '_mod', mod) > object.__setattr__(self, '_encoding', encoding) > object.__setattr__(self, '_overrides', overrides) >+ if cache: >+ cache = {} >+ else: >+ cache = None >+ object.__setattr__(self, '_cache', cache) > > def __getattribute__(self, attr): >+ cache = object.__getattribute__(self, '_cache') >+ if cache is not None: >+ result = cache.get(attr, None) >+ if result is not None: >+ return result > result = getattr(object.__getattribute__(self, '_mod'), attr) > encoding = object.__getattribute__(self, '_encoding') > overrides = object.__getattribute__(self, '_overrides') >@@ -229,6 +238,8 @@ class _unicode_module_wrapper(object): > encoding=encoding, overrides=overrides) > elif hasattr(result, '__call__'): > result = _unicode_func_wrapper(result, encoding=encoding) >+ if cache is not None: >+ cache[attr] = result > return result > > import os as _os
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 276813
:
196987
|
197434
|
197437
|
197827
|
198253
|
203267
|
203269
|
203406
|
203509
|
203512
|
203515
|
203519
|
204572
|
204597
|
204673
|
204685
|
204770
|
204883
|
204996
|
205039