mod_speedups.py :  » Development » Leo » Leo-4.7.1-final » leo » plugins » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Development » Leo 
Leo » Leo 4.7.1 final » leo » plugins » mod_speedups.py
#@+leo-ver=4-thin
#@+node:ville.20090804155017.7590:@thin mod_speedups.py
#@<< docstring >>
#@+node:ville.20090804155017.7591:<< docstring >>
''' Experimental speedups

Various optimizations. Use at your own risk. 

If stuff breaks, disable this plugin before reporting bugs.


'''
#@-node:ville.20090804155017.7591:<< docstring >>
#@nl

__version__ = '0.0'
#@<< version history >>
#@+node:ville.20090804155017.7592:<< version history >>
#@@killcolor
#@+at
# 
# 0.1 VMV first version
#@-at
#@-node:ville.20090804155017.7592:<< version history >>
#@nl

#@<< imports >>
#@+node:ville.20090804155017.7593:<< imports >>
import leo.core.leoGlobals as g
import leo.core.leoPlugins as leoPlugins
import os.path

# Whatever other imports your plugins uses.
#@nonl
#@-node:ville.20090804155017.7593:<< imports >>
#@nl

#@+others
#@+node:ville.20090804155017.7594:init
def init ():

    ok = True # This might depend on imports, etc.

    return ok
#@-node:ville.20090804155017.7594:init
#@+node:ville.20090804155017.7596:g.toUnicodeFileEncoding
def speedup_toUnicodeFileEncoding(s, arg = None):
    #if g:
        #print s,g.callers(10)
    return s    

import leo    

g.toUnicodeFileEncoding = speedup_toUnicodeFileEncoding



#@-node:ville.20090804155017.7596:g.toUnicodeFileEncoding
#@+node:ville.20090804155017.12332:os.path shortcuts
g.os_path_basename = os.path.basename
g.os_path_split = os.path.split
g.os_path_splitext = os.path.splitext
#g.os_path_expanduser = os.path.expanduser
g.os_path_abspath = os.path.abspath
#g.os_path_join = os.path.join
g.os_path_normpath = os.path.normpath
g.os_path_exists = os.path.exists
#g.os_path_finalize = os.path.abspath



#@-node:ville.20090804155017.12332:os.path shortcuts
#@+node:ville.20090804155017.12333:os_path_finalize caching

os_path_finalize_orig = g.os_path_finalize
os_path_finalize_join_orig = g.os_path_finalize_join

_finalized_cache = {}
_finalized_join_cache = {}
_expanduser_cache = {}

def os_path_finalize_cached (path,**keys):
    res = _finalized_cache.get(path)
    if res:
        return res
    res = os_path_finalize_orig(path, **keys)
    _finalized_cache[path] = res
    return res

def os_path_finalize_join_cached (*args,**keys):
    res = _finalized_join_cache.get(args)
    if res:
        #print "cache hit", args
        return res

    res = os_path_finalize_join_orig(*args, **keys)
    _finalized_join_cache[args] = res
    return res

def os_path_expanduser_cached(path, encoding = None):
    res = _expanduser_cache.get(path)
    if res:
        #print "cache hit", path
        return res
    res = os.path.expanduser(path)
    _expanduser_cache[path] = res
    return res

def os_path_join_speedup(*args, **kw):    
    path = os.path.join(*args)
    return path

g.os_path_finalize = os_path_finalize_cached
g.os_path_finalize_join = os_path_finalize_join_cached
g.os_path_expanduser = os_path_expanduser_cached
#g.os_path_join = os_path_join_speedup

#@-node:ville.20090804155017.12333:os_path_finalize caching
#@-others
#@nonl
#@-node:ville.20090804155017.7590:@thin mod_speedups.py
#@-leo
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.