예제 #1
0
def set_jit_option(options, jitparam, *args):
    if 'pypyjit' not in sys.builtin_module_names:
        print >> sys.stderr, ("Warning: No jit support in %s" %
                              (sys.executable,))
    else:
        import pypyjit
        pypyjit.set_param(jitparam)
예제 #2
0
파일: app_main.py 프로젝트: purepython/pypy
def set_jit_option(options, jitparam, *args):
    if 'pypyjit' not in sys.builtin_module_names:
        print >> sys.stderr, ("Warning: No jit support in %s" %
                              (sys.executable, ))
    else:
        import pypyjit
        pypyjit.set_param(jitparam)
예제 #3
0
    def elaborate(s):
        try:
            import pypyjit
            pypyjit.set_param("off")
        except:
            pass

        super().elaborate()
예제 #4
0
파일: app_main.py 프로젝트: mozillazg/pypy
def set_jit_option(options, jitparam, *args):
    if jitparam == 'help':
        _print_jit_help()
        raise SystemExit
    if 'pypyjit' not in sys.builtin_module_names:
        print >> sys.stderr, ("Warning: No jit support in %s" %
                              (get_sys_executable(),))
    else:
        import pypyjit
        pypyjit.set_param(jitparam)
예제 #5
0
파일: app_main.py 프로젝트: sota/pypy
def set_jit_option(options, jitparam, *args):
    if jitparam == 'help':
        _print_jit_help()
        raise SystemExit
    if 'pypyjit' not in sys.builtin_module_names:
        print >> sys.stderr, ("Warning: No jit support in %s" %
                              (get_sys_executable(), ))
    else:
        import pypyjit
        pypyjit.set_param(jitparam)
예제 #6
0
    def apply(s, pass_instance):
        try:
            import pypyjit
            pypyjit.set_param("off")
        except:
            pass

        assert type(pass_instance) is not type, f"Should pass in a pass instance like " \
                                                f"'{pass_instance.__name__}()' instead of '{pass_instance.__name__}'"
        assert callable(
            pass_instance
        ), f"Should override __call__ of {pass_instance.__name__} for a valid pass"
        pass_instance(s)
예제 #7
0
 def test_no_jit(self):
     import pypyjit
     was_called = []
     def should_not_be_called(*args, **kwds):
         was_called.append((args, kwds))
     try:
         pypyjit.set_param('off')
         pypyjit.set_compile_hook(should_not_be_called)
         def f():
             pass
         for i in range(2500):
             f()
         assert not was_called
     finally:
         pypyjit.set_compile_hook(None)
         pypyjit.set_param('default')
예제 #8
0
    def test_setup(self):
        # this just checks that the module is setting up things correctly, and
        # the resulting code makes sense on top of CPython.
        import pypyjit
        pypyjit.set_param(threshold=5, inlining=1)
        pypyjit.set_param("trace_eagerness=3,inlining=0")

        def f(x, y):
            return x * y + 1

        assert f(6, 7) == 43

        def gen(x):
            i = 0
            while i < x:
                yield i * i
                i += 1

        assert list(gen(3)) == [0, 1, 4]
예제 #9
0
    def test_setup(self):
        # this just checks that the module is setting up things correctly, and
        # the resulting code makes sense on top of CPython.
        import pypyjit
        pypyjit.set_param(threshold=5, inlining=1)
        pypyjit.set_param("trace_eagerness=3,inlining=0")

        def f(x, y):
            return x*y+1

        assert f(6, 7) == 43

        def gen(x):
            i = 0
            while i < x:
                yield i*i
                i += 1

        assert list(gen(3)) == [0, 1, 4]
예제 #10
0
    def test_no_jit(self):
        import pypyjit
        was_called = []

        def should_not_be_called(*args, **kwds):
            was_called.append((args, kwds))

        try:
            pypyjit.set_param('off')
            pypyjit.set_compile_hook(should_not_be_called)

            def f():
                pass

            for i in range(2500):
                f()
            assert not was_called
        finally:
            pypyjit.set_compile_hook(None)
            pypyjit.set_param('default')
예제 #11
0
  def apply( s, *args ):
    try:
      import pypyjit
      pypyjit.set_param("off")
    except:
      pass

    if isinstance(args[0], list):
      assert len(args) == 1
      for step in args[0]:
        step( s )

    elif len(args) == 1:
      assert callable( args[0] )
      args[0]( s )

    try:
      pypyjit.set_param("default")
      pypyjit.set_param("trace_limit=100000")
    except:
      pass
예제 #12
0
import sys
import runpy
import pypyjit
from pypy.tool.jitlogparser import parser
from pypy.tool.jitlogparser.storage import LoopStorage

pypyjit.set_param("default")
l = []
l2 = []
l3 = []


def hook(jitdriver_name, loop_type, greenkey, operations, assembler_addr, assembler_length):
    l.append((jitdriver_name, loop_type, greenkey, operations, assembler_addr, assembler_length))
    print "Driver:", jitdriver_name
    print "Type: ", loop_type
    print "Operations:"
    for op in operations:
        print op.name
        print op.num
        if op.name == "debug_merge_point":
            print dir(op.pycode)
            print op.pycode.co_code
        print dir(op)


def hook2(*args):
    l2.append(args)


def hook3(*args):
예제 #13
0
import sys
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
from itertools import combinations, permutations, product, accumulate, groupby
from collections import defaultdict, deque, Counter
from functools import reduce
from operator import add, mul
import heapq as hq
import bisect
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
# = input().strip()
# = int(input())
# = map(int,input().split())
# = list(map(int,input().split()))
# = [input().strip() for i in range(H)]
# = [list(map(int,input().split())) for i in range(N)]
예제 #14
0
import pypyjit
pypyjit.set_param(threshold=200)


def g(*args):
    return len(args)


def f(n):
    s = 0
    for i in range(n):
        l = [i, n, 2]
        s += g(*l)
    return s


try:
    print f(301)

except Exception, e:
    print "Exception: ", type(e)
    print e
예제 #15
0
import pypyjit
pypyjit.set_param(threshold=200)


def g(*args):
    return len(args)

def f(n):
    s = 0
    for i in range(n):
        l = [i, n, 2]
        s += g(*l)
    return s

try:
    print f(301)

except Exception, e:
    print "Exception: ", type(e)
    print e

예제 #16
0
from sys import setrecursionlimit

from pypyjit import set_param

setrecursionlimit(pow(10, 9))
set_param('max_unroll_recursion=-1')


def solve(t, k):
    if t == 0:
        return S[k]
    elif k == 0:
        return chr((ord(S[0]) - 65 + t) % 3 + 65)
    else:
        return chr((ord(solve(t - 1, k // 2)) - 65 + k % 2 + 1) % 3 + 65)


S = input()
Q = int(input())
ans = []
for _ in range(Q):
    t, k = map(int, input().split())
    ans.append(solve(t, k - 1))
print(*ans, sep="\n")
예제 #17
0
from sys import setrecursionlimit

from pypyjit import set_param

setrecursionlimit(pow(10, 9))
set_param("max_unroll_recursion=-1")


def get_jewels(n, is_red) -> int:
    if n <= 1:
        return 0 if is_red else 1
    return get_jewels(n-1, True) + get_jewels(n, False) * X if is_red else get_jewels(n-1, True) + get_jewels(n-1, False) * Y


N, X, Y = map(int, input().split())
print(get_jewels(N, True))
예제 #18
0
파일: app_main.py 프로젝트: enyst/plexnet
def parse_command_line(argv):
    go_interactive = False
    run_command = False
    import_site = True
    i = 0
    run_module = False
    run_stdin = False
    warnoptions = []
    unbuffered = False
    while i < len(argv):
        arg = argv[i]
        if not arg.startswith('-'):
            break
        if arg == '-i':
            go_interactive = True
        elif arg.startswith('-c'):
            cmd, i = get_argument('-c', argv, i)
            argv[i] = '-c'
            run_command = True
            break
        elif arg == '-u':
            unbuffered = True
        elif arg == '-O':
            pass
        elif arg == '--version' or arg == '-V':
            print "Python", sys.version
            return
        elif arg == '--info':
            print_info()
            return
        elif arg == '-h' or arg == '--help':
            print_help()
            return
        elif arg == '-S':
            import_site = False
        elif arg == '-':
            run_stdin = True
            break     # not an option but a file name representing stdin
        elif arg.startswith('-m'):
            module, i = get_argument('-m', argv, i)
            argv[i] = module
            run_module = True
            break
        elif arg.startswith('-W'):
            warnoptions, i = get_argument('-W', argv, i)
        elif arg.startswith('--jit'):
            jitparam, i = get_argument('--jit', argv, i)
            if 'pypyjit' not in sys.builtin_module_names:
                print >> sys.stderr, ("Warning: No jit support in %s" %
                                      (sys.executable,))
            else:
                import pypyjit
                pypyjit.set_param(jitparam)
        elif arg == '--':
            i += 1
            break     # terminates option list    
        else:
            raise CommandLineError('unrecognized option %r' % (arg,))
        i += 1
    sys.argv = argv[i:]
    if not sys.argv:
        sys.argv.append('')
        run_stdin = True
    return locals()
예제 #19
0
import pypyjit
pypyjit.set_param(threshold=3)


def f(a, b):
    return a + b


def g():
    i = 0
    while i < 10:
        a = 'foo'
        i += 1


def h():
    [x for x in range(10)]


g()
h()
예제 #20
0

if __name__ == '__main__':
    from io import mplayer, view
    import sys
    from time import time

    if len(sys.argv) > 1:
        fn = sys.argv[1]
    else:
        fn = 'test.avi -vf scale=640:480 -benchmark'

    sys.setcheckinterval(2**30)
    try:
        import pypyjit
        pypyjit.set_param(trace_limit=200000)
    except ImportError:
        pass

    start = start0 = time()
    for fcnt, img in enumerate(mplayer(Image, fn)):
        #view(img)
        view(sobel_magnitude(img))
        #view(sobel_magnitude_generator(img))
        #sobel_magnitude_generator(img)
        #sobel_magnitude(img)
        print 1.0 / (time() - start), 'fps, ', (fcnt - 2) / (
            time() - start0), 'average fps'
        start = time()
        if fcnt == 2:
            start0 = time()
예제 #21
0
def parse_command_line(argv):
    go_interactive = False
    run_command = False
    import_site = True
    i = 0
    run_module = False
    run_stdin = False
    warnoptions = []
    unbuffered = False
    while i < len(argv):
        arg = argv[i]
        if not arg.startswith('-'):
            break
        if arg == '-i':
            go_interactive = True
        elif arg.startswith('-c'):
            cmd, i = get_argument('-c', argv, i)
            argv[i] = '-c'
            run_command = True
            break
        elif arg == '-u':
            unbuffered = True
        elif arg == '-O':
            pass
        elif arg == '--version' or arg == '-V':
            print "Python", sys.version
            return
        elif arg == '--info':
            print_info()
            return
        elif arg == '-h' or arg == '--help':
            print_help()
            return
        elif arg == '-S':
            import_site = False
        elif arg == '-':
            run_stdin = True
            break  # not an option but a file name representing stdin
        elif arg.startswith('-m'):
            module, i = get_argument('-m', argv, i)
            argv[i] = module
            run_module = True
            break
        elif arg.startswith('-W'):
            warnoptions, i = get_argument('-W', argv, i)
        elif arg.startswith('--jit'):
            jitparam, i = get_argument('--jit', argv, i)
            if 'pypyjit' not in sys.builtin_module_names:
                print >> sys.stderr, ("Warning: No jit support in %s" %
                                      (sys.executable, ))
            else:
                import pypyjit
                pypyjit.set_param(jitparam)
        elif arg == '--':
            i += 1
            break  # terminates option list
        else:
            raise CommandLineError('unrecognized option %r' % (arg, ))
        i += 1
    sys.argv = argv[i:]
    if not sys.argv:
        sys.argv.append('')
        run_stdin = True
    return locals()
예제 #22
0
import unittest
import os


def rel(*args):
    """ Return a path relative to this file """
    return os.path.join(os.path.dirname(__file__), *args)


from vproc.IO import MPlayer
from vproc.video import Video
from vproc.overlayable import Text, Logo, SlideAnimation, FadeAnimation

try:
    import pypyjit
    pypyjit.set_param(trace_limit=200000)
except:
    raise

class VideoTest(unittest.TestCase):
    def test_header(self):
        v = Video(rel("breakfast.mpg"))
        stream = MPlayer(v)
        self.assertNotEquals(stream.next_frame(), None)

    def test_duration(self):
        v = Video(rel('breakfast.mpg'))
        self.assertEquals(v.duration, 1.6)

if __name__ == '__main__':
    unittest.main()
예제 #23
0
파일: x.py 프로젝트: Darriall/pypy
import pypyjit
pypyjit.set_param(threshold=3)

def f(a, b):
    return a + b

def g():
    i = 0
    while i < 10:
        a = 'foo'
        i += 1

def h():
    [x for x in range(10)]

g()
h()