[pypy-svn] r79668 - in pypy/trunk/lib_pypy: . pypy_test

arigo at codespeak.net arigo at codespeak.net
Tue Nov 30 14:09:13 CET 2010


Author: arigo
Date: Tue Nov 30 14:09:09 2010
New Revision: 79668

Added:
   pypy/trunk/lib_pypy/pypy_test/hack___pypy__.py
Modified:
   pypy/trunk/lib_pypy/_hashlib.py
   pypy/trunk/lib_pypy/_locale.py
   pypy/trunk/lib_pypy/_marshal.py
   pypy/trunk/lib_pypy/_minimal_curses.py
   pypy/trunk/lib_pypy/cPickle.py
   pypy/trunk/lib_pypy/cmath.py
   pypy/trunk/lib_pypy/grp.py
   pypy/trunk/lib_pypy/itertools.py
   pypy/trunk/lib_pypy/msvcrt.py
   pypy/trunk/lib_pypy/pwd.py
   pypy/trunk/lib_pypy/pyexpat.py
   pypy/trunk/lib_pypy/pypy_test/test_hashlib.py
   pypy/trunk/lib_pypy/pypy_test/test_structseq.py
   pypy/trunk/lib_pypy/readline.py
   pypy/trunk/lib_pypy/resource.py
   pypy/trunk/lib_pypy/syslog.py
Log:
A first round of adding @__pypy__.builtinify a bit everywhere... :-(


Modified: pypy/trunk/lib_pypy/_hashlib.py
==============================================================================
--- pypy/trunk/lib_pypy/_hashlib.py	(original)
+++ pypy/trunk/lib_pypy/_hashlib.py	Tue Nov 30 14:09:09 2010
@@ -148,29 +148,29 @@
     return hash(ctx, name)
 
 # shortcut functions
-from __pypy__ import builtinify
+import __pypy__
 
- at builtinify
+ at __pypy__.builtinify
 def openssl_md5(string=''):
     return new('md5', string)
 
- at builtinify
+ at __pypy__.builtinify
 def openssl_sha1(string=''):
     return new('sha1', string)
 
- at builtinify
+ at __pypy__.builtinify
 def openssl_sha224(string=''):
     return new('sha224', string)
 
- at builtinify
+ at __pypy__.builtinify
 def openssl_sha256(string=''):
     return new('sha256', string)
 
- at builtinify
+ at __pypy__.builtinify
 def openssl_sha384(string=''):
     return new('sha384', string)
 
- at builtinify
+ at __pypy__.builtinify
 def openssl_sha512(string=''):
     return new('sha512', string)
 

Modified: pypy/trunk/lib_pypy/_locale.py
==============================================================================
--- pypy/trunk/lib_pypy/_locale.py	(original)
+++ pypy/trunk/lib_pypy/_locale.py	Tue Nov 30 14:09:09 2010
@@ -11,6 +11,8 @@
 # load the platform-specific cache made by running locale.ctc.py
 from ctypes_config_cache._locale_cache import *
 
+import __pypy__
+
 
 # Ubuntu Gusty i386 structure
 class lconv(Structure):
@@ -158,6 +160,7 @@
     ul = ''.join(ul)
     string.letters = ul
 
+ at __pypy__.builtinify
 def setlocale(category, locale=None):
     "(integer,string=None) -> string. Activates/queries locale processing."
     if locale:
@@ -182,6 +185,7 @@
         groups.append(0)
     return groups
 
+ at __pypy__.builtinify
 def localeconv():
     "() -> dict. Returns numeric and monetary locale-specific parameters."
 
@@ -215,6 +219,7 @@
     }
     return result
 
+ at __pypy__.builtinify
 def strcoll(s1, s2):
     "string,string -> int. Compares two strings according to the locale."
 
@@ -233,6 +238,7 @@
     # Collate the strings.
     return _wcscoll(s1, s2)
 
+ at __pypy__.builtinify
 def strxfrm(s):
     "string -> string. Returns a string that behaves for cmp locale-aware."
 
@@ -246,6 +252,7 @@
         _strxfrm(buf, s, n2)
     return buf.value
 
+ at __pypy__.builtinify
 def getdefaultlocale():
     # TODO: Port code from CPython for Windows and Mac OS
     raise NotImplementedError()
@@ -267,26 +274,31 @@
         raise ValueError("unsupported langinfo constant")
 
 if HAS_LIBINTL:
+    @__pypy__.builtinify
     def gettext(msg):
         """gettext(msg) -> string
         Return translation of msg."""
         return _gettext(msg)
 
+    @__pypy__.builtinify
     def dgettext(domain, msg):
         """dgettext(domain, msg) -> string
         Return translation of msg in domain."""
         return _dgettext(domain, msg)
 
+    @__pypy__.builtinify
     def dcgettext(domain, msg, category):
         """dcgettext(domain, msg, category) -> string
         Return translation of msg in domain and category."""
         return _dcgettext(domain, msg, category)
 
+    @__pypy__.builtinify
     def textdomain(domain):
         """textdomain(domain) -> string
         Set the C library's textdomain to domain, returning the new domain."""
         return _textdomain(domain)
 
+    @__pypy__.builtinify
     def bindtextdomain(domain, dir):
         """bindtextdomain(domain, dir) -> string
         Bind the C library's domain to dir."""
@@ -297,6 +309,7 @@
         return dirname
 
     if HAS_BIND_TEXTDOMAIN_CODESET:
+        @__pypy__.builtinify
         def bind_textdomain_codeset(domain, codeset):
             """bind_textdomain_codeset(domain, codeset) -> string
             Bind the C library's domain to codeset."""

Modified: pypy/trunk/lib_pypy/_marshal.py
==============================================================================
--- pypy/trunk/lib_pypy/_marshal.py	(original)
+++ pypy/trunk/lib_pypy/_marshal.py	Tue Nov 30 14:09:09 2010
@@ -3,7 +3,7 @@
 This module contains functions that can read and write Python values in a binary format. The format is specific to Python, but independent of machine architecture issues (e.g., you can write a Python value to a file on a PC, transport the file to a Sun, and read it back there). Details of the format may change between Python versions.
 """
 
-import types
+import types, __pypy__
 from _codecs import utf_8_decode, utf_8_encode
 
 TYPE_NULL     = '0'
@@ -645,15 +645,18 @@
 
 version = 1
 
+ at __pypy__.builtinify
 def dump(x, f, version=version):
     # XXX 'version' is ignored, we always dump in a version-0-compatible format
     m = _Marshaller(f.write)
     m.dump(x)
 
+ at __pypy__.builtinify
 def load(f):
     um = _Unmarshaller(f.read)
     return um.load()
 
+ at __pypy__.builtinify
 def dumps(x, version=version):
     # XXX 'version' is ignored, we always dump in a version-0-compatible format
     buffer = []
@@ -661,6 +664,7 @@
     m.dump(x)
     return ''.join(buffer)
 
+ at __pypy__.builtinify
 def loads(s):
     um = _FastUnmarshaller(s)
     return um.load()

Modified: pypy/trunk/lib_pypy/_minimal_curses.py
==============================================================================
--- pypy/trunk/lib_pypy/_minimal_curses.py	(original)
+++ pypy/trunk/lib_pypy/_minimal_curses.py	Tue Nov 30 14:09:09 2010
@@ -35,18 +35,23 @@
 
 # ____________________________________________________________
 
+import __pypy__
+
+ at __pypy__.builtinify
 def setupterm(termstr, fd):
     err = ctypes.c_int(0)
     result = clib.setupterm(termstr, fd, ctypes.byref(err))
     if result == ERR:
         raise error("setupterm() failed (err=%d)" % err.value)
 
+ at __pypy__.builtinify
 def tigetstr(cap):
     result = clib.tigetstr(cap)
     if ctypes.cast(result, ctypes.c_void_p).value == ERR:
         return None
     return ctypes.cast(result, ctypes.c_char_p).value
 
+ at __pypy__.builtinify
 def tparm(str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0, i9=0):
     result = clib.tparm(str, i1, i2, i3, i4, i5, i6, i7, i8, i9)
     if result is None:

Modified: pypy/trunk/lib_pypy/cPickle.py
==============================================================================
--- pypy/trunk/lib_pypy/cPickle.py	(original)
+++ pypy/trunk/lib_pypy/cPickle.py	Tue Nov 30 14:09:09 2010
@@ -4,6 +4,7 @@
 
 from pickle import *
 from pickle import __doc__, __version__, format_version, compatible_formats
+import __pypy__
 
 BadPickleGet = KeyError
 UnpickleableError = PicklingError
@@ -31,9 +32,11 @@
     def getvalue(self):
         return self.__f and self.__f.getvalue()
 
+ at __pypy__.builtinify
 def dump(obj, file, protocol=None):
     Pickler(file, protocol).dump(obj)
 
+ at __pypy__.builtinify
 def dumps(obj, protocol=None):
     file = StringIO()
     Pickler(file, protocol).dump(obj)

Modified: pypy/trunk/lib_pypy/cmath.py
==============================================================================
--- pypy/trunk/lib_pypy/cmath.py	(original)
+++ pypy/trunk/lib_pypy/cmath.py	Tue Nov 30 14:09:09 2010
@@ -5,9 +5,9 @@
 
 # much code borrowed from mathmodule.c
 
-import math
+import math, __pypy__
 from math import e, pi
-        
+
 
 # constants
 _one = complex(1., 0.)
@@ -24,6 +24,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def acos(x):
     """acos(x)
 
@@ -32,6 +33,7 @@
     return -(_prodi(log((x+(_i*sqrt((_one-(x*x))))))))
 
 
+ at __pypy__.builtinify
 def acosh(x):
     """acosh(x)
 
@@ -41,6 +43,7 @@
     return z+z
 
 
+ at __pypy__.builtinify
 def asin(x):
     """asin(x)
 
@@ -52,6 +55,7 @@
     return -(_prodi(log((sqrt_1_minus_x_sq+_prodi(x)))))
 
 
+ at __pypy__.builtinify
 def asinh(x):
     """asinh(x)
 
@@ -61,6 +65,7 @@
     return z+z
 
 
+ at __pypy__.builtinify
 def atan(x):
     """atan(x)
     
@@ -69,6 +74,7 @@
     return _halfi*log(((_i+x)/(_i-x)))
 
 
+ at __pypy__.builtinify
 def atanh(x):
     """atanh(x)
 
@@ -77,6 +83,7 @@
     return _half*log((_one+x)/(_one-x))
 
 
+ at __pypy__.builtinify
 def cos(x):
     """cos(x)
 
@@ -88,6 +95,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def cosh(x):
     """cosh(x)
     
@@ -99,6 +107,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def exp(x):
     """exp(x)
     
@@ -111,6 +120,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def log(x, base=None):
     """log(x)
 
@@ -125,6 +135,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def log10(x):
     """log10(x)
 
@@ -137,6 +148,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def sin(x):
     """sin(x)
 
@@ -148,6 +160,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def sinh(x):
     """sinh(x)
 
@@ -159,6 +172,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def sqrt(x):
     """sqrt(x)
 
@@ -184,6 +198,7 @@
 _sqrt_half = sqrt(_half)
 
 
+ at __pypy__.builtinify
 def tan(x):
     """tan(x)
 
@@ -204,6 +219,7 @@
     return complex(real, imag)
 
 
+ at __pypy__.builtinify
 def tanh(x):
     """tanh(x)
 

Modified: pypy/trunk/lib_pypy/grp.py
==============================================================================
--- pypy/trunk/lib_pypy/grp.py	(original)
+++ pypy/trunk/lib_pypy/grp.py	Tue Nov 30 14:09:09 2010
@@ -2,7 +2,7 @@
 """ This module provides ctypes version of cpython's grp module
 """
 
-import sys
+import sys, __pypy__
 if sys.platform == 'win32':
     raise ImportError("No grp module on Windows")
 
@@ -64,6 +64,7 @@
     return Group(res.contents.gr_name, res.contents.gr_passwd,
                  res.contents.gr_gid, mem)
 
+ at __pypy__.builtinify
 def getgrgid(gid):
     res = libc.getgrgid(gid)
     if not res:
@@ -71,6 +72,7 @@
         raise KeyError(gid)
     return _group_from_gstruct(res)
 
+ at __pypy__.builtinify
 def getgrnam(name):
     if not isinstance(name, str):
         raise TypeError("expected string")
@@ -79,6 +81,7 @@
         raise KeyError(name)
     return _group_from_gstruct(res)
 
+ at __pypy__.builtinify
 def getgrall():
     libc.setgrent()
     lst = []

Modified: pypy/trunk/lib_pypy/itertools.py
==============================================================================
--- pypy/trunk/lib_pypy/itertools.py	(original)
+++ pypy/trunk/lib_pypy/itertools.py	Tue Nov 30 14:09:09 2010
@@ -27,6 +27,8 @@
            'ifilterfalse', 'imap', 'islice', 'izip', 'repeat', 'starmap',
            'takewhile', 'tee']
 
+import __pypy__
+
 
 class chain(object):
     """Make an iterator that returns elements from the first iterable
@@ -565,7 +567,8 @@
     def __iter__(self):
         return self
 
-    
+
+ at __pypy__.builtinify
 def tee(iterable, n=2):
     """Return n independent iterators from a single iterable.
     Note : once tee() has made a split, the original iterable

Modified: pypy/trunk/lib_pypy/msvcrt.py
==============================================================================
--- pypy/trunk/lib_pypy/msvcrt.py	(original)
+++ pypy/trunk/lib_pypy/msvcrt.py	Tue Nov 30 14:09:09 2010
@@ -11,6 +11,7 @@
 from ctypes_support import standard_c_lib as _c
 from ctypes_support import get_errno
 import errno
+import __pypy__
 
 try:
     open_osfhandle = _c._open_osfhandle
@@ -34,6 +35,7 @@
 _locking.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_int]
 _locking.restype = ctypes.c_int
 
+ at __pypy__.builtinify
 def locking(fd, mode, nbytes):
     '''lock or unlock a number of bytes in a file.'''
     rv = _locking(fd, mode, nbytes)

Modified: pypy/trunk/lib_pypy/pwd.py
==============================================================================
--- pypy/trunk/lib_pypy/pwd.py	(original)
+++ pypy/trunk/lib_pypy/pwd.py	Tue Nov 30 14:09:09 2010
@@ -10,7 +10,7 @@
 exception is raised if the entry asked for cannot be found.
 """
 
-import sys
+import sys, __pypy__
 if sys.platform == 'win32':
     raise ImportError("No pwd module on Windows")
 
@@ -79,10 +79,12 @@
 _endpwent.argtypes = None
 _endpwent.restype = None
 
+ at __pypy__.builtinify
 def mkpwent(pw):
     pw = pw.contents
     return struct_passwd(pw)
 
+ at __pypy__.builtinify
 def getpwuid(uid):
     """
     getpwuid(uid) -> (pw_name,pw_passwd,pw_uid,
@@ -95,6 +97,7 @@
         raise KeyError("getpwuid(): uid not found: %s" % uid)
     return mkpwent(pw)
 
+ at __pypy__.builtinify
 def getpwnam(name):
     """
     getpwnam(name) -> (pw_name,pw_passwd,pw_uid,
@@ -109,9 +112,10 @@
         raise KeyError("getpwname(): name not found: %s" % name)
     return mkpwent(pw)
 
+ at __pypy__.builtinify
 def getpwall():
     """
-    "getpwall() -> list_of_entries
+    getpwall() -> list_of_entries
     Return a list of all available password database entries, in arbitrary order.
     See pwd.__doc__ for more on password database entries.
     """

Modified: pypy/trunk/lib_pypy/pyexpat.py
==============================================================================
--- pypy/trunk/lib_pypy/pyexpat.py	(original)
+++ pypy/trunk/lib_pypy/pyexpat.py	Tue Nov 30 14:09:09 2010
@@ -2,7 +2,7 @@
 import ctypes
 import ctypes.util
 from ctypes import c_char_p, c_int, c_void_p, POINTER, c_char, c_wchar_p
-import sys
+import sys, __pypy__
 
 # load the platform-specific cache made by running pyexpat.ctc.py
 from ctypes_config_cache._pyexpat_cache import *
@@ -425,9 +425,11 @@
         new_parser._set_unknown_encoding_handler()
         return new_parser
 
+ at __pypy__.builtinify
 def ErrorString(errno):
     return XML_ErrorString(errno)[:200]
 
+ at __pypy__.builtinify
 def ParserCreate(encoding=None, namespace_separator=None, intern=None):
     if (not isinstance(encoding, str) and
         not encoding is None):

Added: pypy/trunk/lib_pypy/pypy_test/hack___pypy__.py
==============================================================================
--- (empty file)
+++ pypy/trunk/lib_pypy/pypy_test/hack___pypy__.py	Tue Nov 30 14:09:09 2010
@@ -0,0 +1,9 @@
+# here only to make test runs work even if not running on top of PyPy
+import sys, new
+
+def builtinify(f):
+    return f
+
+pypy = new.module('__pypy__')
+pypy.builtinify = builtinify
+sys.modules.setdefault('__pypy__', pypy)

Modified: pypy/trunk/lib_pypy/pypy_test/test_hashlib.py
==============================================================================
--- pypy/trunk/lib_pypy/pypy_test/test_hashlib.py	(original)
+++ pypy/trunk/lib_pypy/pypy_test/test_hashlib.py	Tue Nov 30 14:09:09 2010
@@ -2,6 +2,7 @@
 from ..ctypes_config_cache import rebuild
 rebuild.rebuild_one('hashlib.ctc.py')
 
+from . import hack___pypy__
 from .. import hashlib, _hashlib
 
 def test_unicode():

Modified: pypy/trunk/lib_pypy/pypy_test/test_structseq.py
==============================================================================
--- pypy/trunk/lib_pypy/pypy_test/test_structseq.py	(original)
+++ pypy/trunk/lib_pypy/pypy_test/test_structseq.py	Tue Nov 30 14:09:09 2010
@@ -1,6 +1,6 @@
 from __future__ import absolute_import
 import py
-from .._structseq import *
+from .._structseq import structseqfield, structseqtype
 
 
 class mydata:

Modified: pypy/trunk/lib_pypy/readline.py
==============================================================================
--- pypy/trunk/lib_pypy/readline.py	(original)
+++ pypy/trunk/lib_pypy/readline.py	Tue Nov 30 14:09:09 2010
@@ -6,8 +6,10 @@
 are only stubs at the moment.
 """
 
-# Note that PyPy contains also a built-in module 'readline' which will hide
-# this one if compiled in.  However the built-in module is incomplete;
-# don't use it.
+import __pypy__
 
-from pyrepl.readline import *
+import pyrepl.readline
+__all__ = pyrepl.readline.__all__
+
+for _name in __all__:
+    globals()[_name] = __pypy__.builtinify(getattr(pyrepl.readline, _name))

Modified: pypy/trunk/lib_pypy/resource.py
==============================================================================
--- pypy/trunk/lib_pypy/resource.py	(original)
+++ pypy/trunk/lib_pypy/resource.py	Tue Nov 30 14:09:09 2010
@@ -1,4 +1,4 @@
-import sys
+import sys, __pypy__
 if sys.platform == 'win32':
     raise ImportError('resource module not available for win32')
 
@@ -77,6 +77,7 @@
     ru_nvcsw = _structseq.structseqfield(14)
     ru_nivcsw = _structseq.structseqfield(15)
 
+ at __pypy__.builtinify
 def rlimit_check_bounds(rlim_cur, rlim_max):
     if rlim_cur > rlim_t_max:
         raise ValueError("%d does not fit into rlim_t" % rlim_cur)
@@ -89,6 +90,7 @@
         ("rlim_max", rlim_t),
     )
 
+ at __pypy__.builtinify
 def getrusage(who):
     ru = _struct_rusage()
     ret = _getrusage(who, byref(ru))
@@ -116,6 +118,7 @@
         ru.ru_nivcsw,
         ))
 
+ at __pypy__.builtinify
 def getrlimit(resource):
     if not(0 <= resource < RLIM_NLIMITS):
         return ValueError("invalid resource specified")
@@ -127,6 +130,7 @@
         raise error(errno)
     return (rlim.rlim_cur, rlim.rlim_max)
 
+ at __pypy__.builtinify
 def setrlimit(resource, rlim):
     if not(0 <= resource < RLIM_NLIMITS):
         return ValueError("invalid resource specified")
@@ -143,6 +147,7 @@
         else:
             raise error(errno)
 
+ at __pypy__.builtinify
 def getpagesize():
     pagesize = 0
     if _getpagesize:

Modified: pypy/trunk/lib_pypy/syslog.py
==============================================================================
--- pypy/trunk/lib_pypy/syslog.py	(original)
+++ pypy/trunk/lib_pypy/syslog.py	Tue Nov 30 14:09:09 2010
@@ -5,7 +5,7 @@
 syslog facility.
 """
 
-import sys
+import sys, __pypy__
 if sys.platform == 'win32':
     raise ImportError("No syslog on Windows")
 
@@ -34,9 +34,11 @@
 _setlogmask.argtypes = (c_int,)
 _setlogmask.restype = c_int
 
+ at __pypy__.builtinify
 def openlog(ident, option, facility):
     _openlog(ident, option, facility)
 
+ at __pypy__.builtinify
 def syslog(arg1, arg2=None):
     if arg2 is not None:
         priority, message = arg1, arg2
@@ -44,15 +46,19 @@
         priority, message = LOG_INFO, arg1
     _syslog(priority, "%s", message)
 
+ at __pypy__.builtinify
 def closelog():
     _closelog()
 
+ at __pypy__.builtinify
 def setlogmask(mask):
     return _setlogmask(mask)
 
+ at __pypy__.builtinify
 def LOG_MASK(pri):
     return (1 << pri)
 
+ at __pypy__.builtinify
 def LOG_UPTO(pri):
     return (1 << (pri + 1)) - 1
 



More information about the Pypy-commit mailing list