[pypy-commit] pypy default: Add documentation.

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44093:a222d1b5e6fe
Date: 2011-05-12 11:47 +0200
http://bitbucket.org/pypy/pypy/changeset/a222d1b5e6fe/

Log:Add documentation.

diff --git a/pypy/doc/config/objspace.usemodules._multibytecodec.txt 
b/pypy/doc/config/objspace.usemodules._multibytecodec.txt
new file mode 100644
--- /dev/null
+++ b/pypy/doc/config/objspace.usemodules._multibytecodec.txt
@@ -0,0 +1,6 @@
+Use the '_multibytecodec' module.
+Used by the standard library to provide codecs for 'gb2312', 'gbk', 'gb18030',
+'hz', 'big5hkscs', 'iso2022_kr', 'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2',
+'iso2022_jp_2004', 'iso2022_jp_3', 'iso2022_jp_ext', 'shift_jis', 'cp932',
+'euc_jp', 'shift_jis_2004', 'euc_jis_2004', 'euc_jisx0213', 'shift_jisx0213',
+'euc_kr', 'cp949', 'johab', 'big5', 'cp950'.
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy unpickle-coroutine-trampoline: fix unpickling of unbound coroutines

2011-05-12 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: unpickle-coroutine-trampoline
Changeset: r44094:8d0c3802413e
Date: 2011-05-12 12:48 +0200
http://bitbucket.org/pypy/pypy/changeset/8d0c3802413e/

Log:fix unpickling of unbound coroutines

diff --git a/pypy/module/_stackless/interp_coroutine.py 
b/pypy/module/_stackless/interp_coroutine.py
--- a/pypy/module/_stackless/interp_coroutine.py
+++ b/pypy/module/_stackless/interp_coroutine.py
@@ -232,7 +232,10 @@
 ec = self.space.getexecutioncontext()
 self.subctx.setstate(space, w_state)
 if space.is_w(w_thunk, space.w_None):
-self.bind(_ResumeThunk(space, self.costate, self.subctx.topframe))
+if space.is_w(w_state, space.w_None):
+self.thunk = None
+else:
+self.bind(_ResumeThunk(space, self.costate, 
self.subctx.topframe))
 else:
 w_func, w_args, w_kwds = space.unpackiterable(w_thunk,
   expected_length=3)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy x86-dump-labels: refactoring: instead of storing a list of "labels", we store a mapping between ops and offsets. Next step is to print the offsets directly in the jit-lot-opt sectio

2011-05-12 Thread antocuni
Author: Antonio Cuni 
Branch: x86-dump-labels
Changeset: r44095:14e8b6b078ac
Date: 2011-05-11 17:51 +0200
http://bitbucket.org/pypy/pypy/changeset/14e8b6b078ac/

Log:refactoring: instead of storing a list of "labels", we store a
mapping between ops and offsets. Next step is to print the offsets
directly in the jit-lot-opt section of the log

diff --git a/pypy/jit/backend/x86/codebuf.py b/pypy/jit/backend/x86/codebuf.py
--- a/pypy/jit/backend/x86/codebuf.py
+++ b/pypy/jit/backend/x86/codebuf.py
@@ -27,14 +27,17 @@
 # at [p-4:p] encode an absolute address that will need to be
 # made relative.
 self.relocations = []
-self.labels = []
+# ResOperation --> offset in the assembly.
+# labels[None] represents the beginning of the code after the last op
+# (i.e., the tail of the loop
+self.labels = {}
 
 def add_pending_relocation(self):
 self.relocations.append(self.get_relative_pos())
 
-def mark_label(self, name):
+def mark_op(self, op):
 pos = self.get_relative_pos()
-self.labels.append((pos, name))
+self.labels[op] = pos
 
 def copy_to_raw_memory(self, addr):
 self._copy_to_raw_memory(addr)
@@ -44,13 +47,3 @@
 adr[0] = intmask(adr[0] - p)
 valgrind.discard_translations(addr, self.get_relative_pos())
 self._dump(addr, "jit-backend-dump", backend_name)
-self.dump_labels(addr, "jit-backend-dump-labels")
-
-def dump_labels(self, addr, logname):
-debug_start(logname)
-if have_debug_prints():
-debug_print('LABELS @%x' % addr)
-for offset, name in self.labels:
-debug_print('+%d: %s' % (offset, name))
-debug_stop(logname)
-
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -406,7 +406,7 @@
 #self.operations = operations
 while i < len(operations):
 op = operations[i]
-self.assembler.mc.mark_label(op.repr())
+self.assembler.mc.mark_op(op)
 self.rm.position = i
 self.xrm.position = i
 if op.has_no_side_effect() and op.result not in self.longevity:
@@ -425,7 +425,7 @@
 i += 1
 assert not self.rm.reg_bindings
 assert not self.xrm.reg_bindings
-self.assembler.mc.mark_label('--end of the loop--')
+self.assembler.mc.mark_op(None) # end of the loop
 
 def _compute_vars_longevity(self, inputargs, operations):
 # compute a dictionary that maps variables to index in
diff --git a/pypy/jit/backend/x86/runner.py b/pypy/jit/backend/x86/runner.py
--- a/pypy/jit/backend/x86/runner.py
+++ b/pypy/jit/backend/x86/runner.py
@@ -61,15 +61,19 @@
 self.profile_agent.shutdown()
 
 def dump_loop_token(self, looptoken):
+"""
+NOT_RPYTHON
+"""
 from pypy.jit.backend.x86.tool.viewcode import machine_code_dump
 data = []
+label_list = [(offset, name) for name, offset in 
looptoken._x86_labels.iteritems()]
+label_list.sort()
 addr = looptoken._x86_rawstart
 src = rffi.cast(rffi.CCHARP, addr)
 for p in range(looptoken._x86_fullsize):
 data.append(src[p])
 data = ''.join(data)
-lines = machine_code_dump(data, addr, self.backend_name,
-  labels=looptoken._x86_labels)
+lines = machine_code_dump(data, addr, self.backend_name, label_list)
 print ''.join(lines)
 
 def compile_loop(self, inputargs, operations, looptoken, log=True):
diff --git a/pypy/jit/backend/x86/test/test_runner.py 
b/pypy/jit/backend/x86/test/test_runner.py
--- a/pypy/jit/backend/x86/test/test_runner.py
+++ b/pypy/jit/backend/x86/test/test_runner.py
@@ -405,30 +405,15 @@
 debug._log = dlog = debug.DebugLog()
 self.cpu.compile_loop(inputargs, operations, looptoken)
 debug._log = None
-expected = ['getfield_raw',
-'int_add',
-'setfield_raw',
-'int_add',
-'int_le',
-'jump',
-'--end of the loop--']
 #
 # check the labels saved on the looptoken
 labels = looptoken._x86_labels
-assert len(labels) == len(expected)
-for (off, lbl), exp_lbl in zip(labels, expected):
-assert exp_lbl in lbl
-#
-# -
-# check the labels dumped to the log
-# discards code blocks which do not belong to loops
-dumped_labels, = [content for category, content in dlog
-  if (category == 'jit-backend-dump-labels' and
-  len(content) > 1)]
-# the first debug_print is LABELS @address
-assert len(dumped_labels) == len(expected) + 1
-for (_, lbl), e

[pypy-commit] pypy x86-dump-labels: actually print the offsets in the log

2011-05-12 Thread antocuni
Author: Antonio Cuni 
Branch: x86-dump-labels
Changeset: r44097:bd0a0aaf7b2e
Date: 2011-05-12 13:26 +0200
http://bitbucket.org/pypy/pypy/changeset/bd0a0aaf7b2e/

Log:actually print the offsets in the log

diff --git a/pypy/jit/metainterp/logger.py b/pypy/jit/metainterp/logger.py
--- a/pypy/jit/metainterp/logger.py
+++ b/pypy/jit/metainterp/logger.py
@@ -17,30 +17,30 @@
 def log_loop(self, inputargs, operations, number=0, type=None, 
labels=None):
 if type is None:
 debug_start("jit-log-noopt-loop")
-self._log_operations(inputargs, operations)
+self._log_operations(inputargs, operations, labels)
 debug_stop("jit-log-noopt-loop")
 else:
 debug_start("jit-log-opt-loop")
 debug_print("# Loop", number, ":", type,
 "with", len(operations), "ops")
-self._log_operations(inputargs, operations)
+self._log_operations(inputargs, operations, labels)
 debug_stop("jit-log-opt-loop")
 
 def log_bridge(self, inputargs, operations, number=-1, labels=None):
 if number == -1:
 debug_start("jit-log-noopt-bridge")
-self._log_operations(inputargs, operations)
+self._log_operations(inputargs, operations, labels)
 debug_stop("jit-log-noopt-bridge")
 else:
 debug_start("jit-log-opt-bridge")
 debug_print("# bridge out of Guard", number,
 "with", len(operations), "ops")
-self._log_operations(inputargs, operations)
+self._log_operations(inputargs, operations, labels)
 debug_stop("jit-log-opt-bridge")
 
 def log_short_preamble(self, inputargs, operations):
 debug_start("jit-log-short-preamble")
-self._log_operations(inputargs, operations)
+self._log_operations(inputargs, operations, labels=None)
 debug_stop("jit-log-short-preamble")
 
 def repr_of_descr(self, descr):
@@ -75,9 +75,11 @@
 else:
 return '?'
 
-def _log_operations(self, inputargs, operations):
+def _log_operations(self, inputargs, operations, labels):
 if not have_debug_prints():
 return
+if labels is None:
+labels = {}
 memo = {}
 if inputargs is not None:
 args = ", ".join([self.repr_of_arg(memo, arg) for arg in 
inputargs])
@@ -89,6 +91,11 @@
 reclev = op.getarg(1).getint()
 debug_print("debug_merge_point('%s', %s)" % (loc, reclev))
 continue
+offset = labels.get(op, -1)
+if offset == -1:
+s_offset = ""
+else:
+s_offset = "+%d: " % offset
 args = ", ".join([self.repr_of_arg(memo, op.getarg(i)) for i in 
range(op.numargs())])
 if op.result is not None:
 res = self.repr_of_arg(memo, op.result) + " = "
@@ -108,8 +115,11 @@
   for arg in op.getfailargs()]) + 
']'
 else:
 fail_args = ''
-debug_print(res + op.getopname() +
+debug_print(s_offset + res + op.getopname() +
 '(' + args + ')' + fail_args)
+if labels and None in labels:
+offset = labels[None]
+debug_print("+%d: # --end of the loop--" % offset)
 
 
 def int_could_be_an_address(x):
diff --git a/pypy/jit/metainterp/test/test_logger.py 
b/pypy/jit/metainterp/test/test_logger.py
--- a/pypy/jit/metainterp/test/test_logger.py
+++ b/pypy/jit/metainterp/test/test_logger.py
@@ -31,10 +31,10 @@
 return log_stream.getvalue()
 
 class Logger(logger.Logger):
-def log_loop(self, loop, namespace={}):
+def log_loop(self, loop, namespace={}, labels=None):
 self.namespace = namespace
 return capturing(logger.Logger.log_loop, self,
- loop.inputargs, loop.operations)
+ loop.inputargs, loop.operations, labels=labels)
 
 def repr_of_descr(self, descr):
 for k, v in self.namespace.items():
@@ -178,3 +178,27 @@
 output = capturing(bare_logger.log_bridge, [], [], 3)
 assert output.splitlines()[0] == "# bridge out of Guard 3 with 0 ops"
 pure_parse(output)
+
+def test_labels(self):
+inp = '''
+[i0]
+i1 = int_add(i0, 1)
+i2 = int_mul(i1, 2)
+jump(i2)
+'''
+loop = pure_parse(inp)
+ops = loop.operations
+labels = {
+ops[0]: 10,
+ops[2]: 30,
+None: 40
+}
+logger = Logger(self.make_metainterp_sd())
+output = logger.log_loop(loop, labels=labels)
+assert output.strip() == """
+[i0]
++10: i2 = int_add(i0, 1)
+i4 = int_mul(i2, 2)
++30: jump(i4)
++40: # --end of the loop--
+""".strip()
___
pypy-commit mai

[pypy-commit] pypy x86-dump-labels: give the backends a chance to return a "labels" dictionary, which will be later used by the logger

2011-05-12 Thread antocuni
Author: Antonio Cuni 
Branch: x86-dump-labels
Changeset: r44096:d3c68b44b87b
Date: 2011-05-12 10:52 +0200
http://bitbucket.org/pypy/pypy/changeset/d3c68b44b87b/

Log:give the backends a chance to return a "labels" dictionary, which
will be later used by the logger

diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -58,6 +58,14 @@
 Should create and attach a fresh CompiledLoopToken to
 looptoken.compiled_loop_token and stick extra attributes
 on it to point to the compiled loop in assembler.
+
+Optionally, return a ``labels`` dictionary, which maps each operation
+to its offset in the compiled code.  The ``labels`` dictionary is then
+used by the operation logger to print the offsets in the log.  The
+offset representing the end of the last operation is stored in
+``labels[None]``: note that this might not coincide with the end of
+the loop, because usually in the loop footer there is code which does
+not belong to any particular operation.
 """
 raise NotImplementedError
 
@@ -65,6 +73,9 @@
original_loop_token, log=True):
 """Assemble the bridge.
 The FailDescr is the descr of the original guard that failed.
+
+Optionally, return a ``labels`` dictionary.  See the docstring of
+``compiled_loop`` for more informations about it.
 """
 raise NotImplementedError
 
diff --git a/pypy/jit/backend/x86/assembler.py 
b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -361,11 +361,12 @@
 frame_depth + param_depth)
 self.patch_pending_failure_recoveries(rawstart)
 #
+labels = self.mc.labels
 if not we_are_translated():
 # used only by looptoken.dump() -- useful in tests
 looptoken._x86_rawstart = rawstart
 looptoken._x86_fullsize = fullsize
-looptoken._x86_labels = self.mc.labels
+looptoken._x86_labels = labels
 
 looptoken._x86_bootstrap_code = rawstart + bootstrappos
 looptoken._x86_loop_code = rawstart + self.looppos
@@ -376,6 +377,7 @@
 name = "Loop # %s: %s" % (looptoken.number, funcname)
 self.cpu.profile_agent.native_code_written(name,
rawstart, fullsize)
+return labels
 
 def assemble_bridge(self, faildescr, inputargs, operations,
 original_loop_token, log):
@@ -425,12 +427,14 @@
 faildescr._x86_bridge_param_depth = param_depth
 # patch the jump from original guard
 self.patch_jump_for_descr(faildescr, rawstart)
+labels = self.mc.labels
 self.teardown()
 # oprofile support
 if self.cpu.profile_agent is not None:
 name = "Bridge # %s: %s" % (descr_number, funcname)
 self.cpu.profile_agent.native_code_written(name,
rawstart, fullsize)
+return labels
 
 def write_pending_failure_recoveries(self):
 # for each pending guard, generate the code of the recovery stub
diff --git a/pypy/jit/backend/x86/runner.py b/pypy/jit/backend/x86/runner.py
--- a/pypy/jit/backend/x86/runner.py
+++ b/pypy/jit/backend/x86/runner.py
@@ -77,15 +77,15 @@
 print ''.join(lines)
 
 def compile_loop(self, inputargs, operations, looptoken, log=True):
-self.assembler.assemble_loop(inputargs, operations, looptoken,
- log=log)
+return self.assembler.assemble_loop(inputargs, operations, looptoken,
+log=log)
 
 def compile_bridge(self, faildescr, inputargs, operations,
original_loop_token, log=True):
 clt = original_loop_token.compiled_loop_token
 clt.compiling_a_bridge()
-self.assembler.assemble_bridge(faildescr, inputargs, operations,
-   original_loop_token, log=log)
+return self.assembler.assemble_bridge(faildescr, inputargs, operations,
+  original_loop_token, log=log)
 
 def set_future_value_int(self, index, intvalue):
 self.assembler.fail_boxes_int.setitem(index, intvalue)
diff --git a/pypy/jit/backend/x86/test/test_runner.py 
b/pypy/jit/backend/x86/test/test_runner.py
--- a/pypy/jit/backend/x86/test/test_runner.py
+++ b/pypy/jit/backend/x86/test/test_runner.py
@@ -403,11 +403,11 @@
 ]
 inputargs = [i0]
 debug._log = dlog = debug.DebugLog()
-self.cpu.compile_loop(inputargs, operations, looptoken)
+labels = self.cpu.compile_loop(inputargs, operations, looptoken)
 debug._log = None
 #

[pypy-commit] pypy x86-dump-labels: rename labels to ops_offset, which is clearer

2011-05-12 Thread antocuni
Author: Antonio Cuni 
Branch: x86-dump-labels
Changeset: r44098:e720a9242b6b
Date: 2011-05-12 14:01 +0200
http://bitbucket.org/pypy/pypy/changeset/e720a9242b6b/

Log:rename labels to ops_offset, which is clearer

diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -59,11 +59,11 @@
 looptoken.compiled_loop_token and stick extra attributes
 on it to point to the compiled loop in assembler.
 
-Optionally, return a ``labels`` dictionary, which maps each operation
-to its offset in the compiled code.  The ``labels`` dictionary is then
+Optionally, return a ``ops_offset`` dictionary, which maps each 
operation
+to its offset in the compiled code.  The ``ops_offset`` dictionary is 
then
 used by the operation logger to print the offsets in the log.  The
 offset representing the end of the last operation is stored in
-``labels[None]``: note that this might not coincide with the end of
+``ops_offset[None]``: note that this might not coincide with the end of
 the loop, because usually in the loop footer there is code which does
 not belong to any particular operation.
 """
@@ -74,7 +74,7 @@
 """Assemble the bridge.
 The FailDescr is the descr of the original guard that failed.
 
-Optionally, return a ``labels`` dictionary.  See the docstring of
+Optionally, return a ``ops_offset`` dictionary.  See the docstring of
 ``compiled_loop`` for more informations about it.
 """
 raise NotImplementedError
diff --git a/pypy/jit/backend/x86/assembler.py 
b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -361,12 +361,12 @@
 frame_depth + param_depth)
 self.patch_pending_failure_recoveries(rawstart)
 #
-labels = self.mc.labels
+ops_offset = self.mc.ops_offset
 if not we_are_translated():
 # used only by looptoken.dump() -- useful in tests
 looptoken._x86_rawstart = rawstart
 looptoken._x86_fullsize = fullsize
-looptoken._x86_labels = labels
+looptoken._x86_ops_offset = ops_offset
 
 looptoken._x86_bootstrap_code = rawstart + bootstrappos
 looptoken._x86_loop_code = rawstart + self.looppos
@@ -377,7 +377,7 @@
 name = "Loop # %s: %s" % (looptoken.number, funcname)
 self.cpu.profile_agent.native_code_written(name,
rawstart, fullsize)
-return labels
+return ops_offset
 
 def assemble_bridge(self, faildescr, inputargs, operations,
 original_loop_token, log):
@@ -427,14 +427,14 @@
 faildescr._x86_bridge_param_depth = param_depth
 # patch the jump from original guard
 self.patch_jump_for_descr(faildescr, rawstart)
-labels = self.mc.labels
+ops_offset = self.mc.ops_offset
 self.teardown()
 # oprofile support
 if self.cpu.profile_agent is not None:
 name = "Bridge # %s: %s" % (descr_number, funcname)
 self.cpu.profile_agent.native_code_written(name,
rawstart, fullsize)
-return labels
+return ops_offset
 
 def write_pending_failure_recoveries(self):
 # for each pending guard, generate the code of the recovery stub
diff --git a/pypy/jit/backend/x86/codebuf.py b/pypy/jit/backend/x86/codebuf.py
--- a/pypy/jit/backend/x86/codebuf.py
+++ b/pypy/jit/backend/x86/codebuf.py
@@ -27,17 +27,18 @@
 # at [p-4:p] encode an absolute address that will need to be
 # made relative.
 self.relocations = []
+#
 # ResOperation --> offset in the assembly.
-# labels[None] represents the beginning of the code after the last op
-# (i.e., the tail of the loop
-self.labels = {}
+# ops_offset[None] represents the beginning of the code after the last 
op
+# (i.e., the tail of the loop)
+self.ops_offset = {}
 
 def add_pending_relocation(self):
 self.relocations.append(self.get_relative_pos())
 
 def mark_op(self, op):
 pos = self.get_relative_pos()
-self.labels[op] = pos
+self.ops_offset[op] = pos
 
 def copy_to_raw_memory(self, addr):
 self._copy_to_raw_memory(addr)
diff --git a/pypy/jit/backend/x86/runner.py b/pypy/jit/backend/x86/runner.py
--- a/pypy/jit/backend/x86/runner.py
+++ b/pypy/jit/backend/x86/runner.py
@@ -66,7 +66,8 @@
 """
 from pypy.jit.backend.x86.tool.viewcode import machine_code_dump
 data = []
-label_list = [(offset, name) for name, offset in 
looptoken._x86_labels.iteritems()]
+label_list = [(offset, name) for name, off

[pypy-commit] pypy default: Fix: this opaque pointer dance is only for gc references. This fixes

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44099:176802d75314
Date: 2011-05-12 14:46 +0200
http://bitbucket.org/pypy/pypy/changeset/176802d75314/

Log:Fix: this opaque pointer dance is only for gc references. This
fixes test_rsocket, which takes pointers to individual bytes in a
non-gc structure, ending up at odd-valued addresses.

diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py 
b/pypy/rpython/lltypesystem/ll2ctypes.py
--- a/pypy/rpython/lltypesystem/ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/ll2ctypes.py
@@ -616,7 +616,7 @@
 container = llobj._obj.container
 T = lltype.Ptr(lltype.typeOf(container))
 # otherwise it came from integer and we want a c_void_p with
-# the same valu
+# the same value
 if getattr(container, 'llopaque', None):
 no = len(_opaque_objs)
 _opaque_objs.append(container)
@@ -774,7 +774,7 @@
 # CFunctionType.__nonzero__ is broken before Python 2.6
 return lltype.nullptr(T.TO)
 if isinstance(T.TO, lltype.Struct):
-if ptrval & 1: # a tagged pointer
+if T.TO._gckind == 'gc' and ptrval & 1: # a tagged pointer
 gcref = _opaque_objs[ptrval // 2].hide()
 return lltype.cast_opaque_ptr(T, gcref)
 REAL_TYPE = T.TO
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix.

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44100:434e29908fff
Date: 2011-05-12 14:47 +0200
http://bitbucket.org/pypy/pypy/changeset/434e29908fff/

Log:Fix.

diff --git a/pypy/rpython/memory/test/test_gctypelayout.py 
b/pypy/rpython/memory/test/test_gctypelayout.py
--- a/pypy/rpython/memory/test/test_gctypelayout.py
+++ b/pypy/rpython/memory/test/test_gctypelayout.py
@@ -4,6 +4,7 @@
 from pypy.rpython.memory.gctypelayout import gc_pointers_inside
 from pypy.rpython.lltypesystem import lltype, llmemory, rclass
 from pypy.rpython.test.test_llinterp import get_interpreter
+from pypy.rpython.rclass import IR_IMMUTABLE
 from pypy.objspace.flow.model import Constant
 
 class FakeGC:
@@ -101,7 +102,7 @@
 accessor = rclass.FieldListAccessor()
 S3 = lltype.GcStruct('S', ('x', PT), ('y', PT),
  hints={'immutable_fields': accessor})
-accessor.initialize(S3, {'x': ''})
+accessor.initialize(S3, {'x': IR_IMMUTABLE})
 #
 s1 = lltype.malloc(S1)
 adr = llmemory.cast_ptr_to_adr(s1)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix.

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44101:1fb80f51e346
Date: 2011-05-12 14:48 +0200
http://bitbucket.org/pypy/pypy/changeset/1fb80f51e346/

Log:Fix.

diff --git a/pypy/translator/backendopt/test/test_constfold.py 
b/pypy/translator/backendopt/test/test_constfold.py
--- a/pypy/translator/backendopt/test/test_constfold.py
+++ b/pypy/translator/backendopt/test/test_constfold.py
@@ -49,7 +49,7 @@
 accessor = rclass.FieldListAccessor()
 S2 = lltype.GcStruct('S2', ('x', lltype.Signed),
  hints={'immutable_fields': accessor})
-accessor.initialize(S2, {'x': ''})
+accessor.initialize(S2, {'x': rclass.IR_IMMUTABLE})
 test_simple(S2)
 
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: skip this test for cli

2011-05-12 Thread antocuni
Author: Antonio Cuni 
Branch: 
Changeset: r44102:9da896594014
Date: 2011-05-12 12:57 +
http://bitbucket.org/pypy/pypy/changeset/9da896594014/

Log:skip this test for cli

diff --git a/pypy/rpython/test/test_rfloat.py b/pypy/rpython/test/test_rfloat.py
--- a/pypy/rpython/test/test_rfloat.py
+++ b/pypy/rpython/test/test_rfloat.py
@@ -177,7 +177,11 @@
 n1 = x * x
 n2 = y * y * y
 return rfloat.isnan(n1 / n2)
-assert self.interpret(fn, [1e200, 1e200])   # nan
+if self.__class__.__name__ != 'TestCliFloat':
+# the next line currently fails on mono 2.6.7 (ubuntu 11.04), see:
+# https://bugzilla.novell.com/show_bug.cgi?id=692493
+assert self.interpret(fn, [1e200, 1e200])   # nan
+#
 assert not self.interpret(fn, [1e200, 1.0])   # +inf
 assert not self.interpret(fn, [1e200, -1.0])  # -inf
 assert not self.interpret(fn, [42.5, 2.3])# +finite
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44105:c35cd5dfa0ac
Date: 2011-05-12 16:07 +0200
http://bitbucket.org/pypy/pypy/changeset/c35cd5dfa0ac/

Log:merge heads

diff --git a/pypy/module/_multibytecodec/app_multibytecodec.py 
b/pypy/module/_multibytecodec/app_multibytecodec.py
--- a/pypy/module/_multibytecodec/app_multibytecodec.py
+++ b/pypy/module/_multibytecodec/app_multibytecodec.py
@@ -11,24 +11,24 @@
 
 class MultibyteIncrementalEncoder(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteIncrementalEncoder not supported; "
+raise LookupError(
+"MultibyteIncrementalEncoder not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
 
 class MultibyteIncrementalDecoder(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteIncrementalDecoder not supported; "
+raise LookupError(
+"MultibyteIncrementalDecoder not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
 
 class MultibyteStreamReader(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteStreamReader not supported; "
+raise LookupError(
+"MultibyteStreamReader not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
 
 class MultibyteStreamWriter(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteStreamWriter not supported; "
+raise LookupError(
+"MultibyteStreamWriter not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Tweak the error and the message.

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44104:46a214e27708
Date: 2011-05-12 16:07 +0200
http://bitbucket.org/pypy/pypy/changeset/46a214e27708/

Log:Tweak the error and the message.

diff --git a/pypy/module/_multibytecodec/app_multibytecodec.py 
b/pypy/module/_multibytecodec/app_multibytecodec.py
--- a/pypy/module/_multibytecodec/app_multibytecodec.py
+++ b/pypy/module/_multibytecodec/app_multibytecodec.py
@@ -11,24 +11,24 @@
 
 class MultibyteIncrementalEncoder(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteIncrementalEncoder not supported; "
+raise LookupError(
+"MultibyteIncrementalEncoder not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
 
 class MultibyteIncrementalDecoder(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteIncrementalDecoder not supported; "
+raise LookupError(
+"MultibyteIncrementalDecoder not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
 
 class MultibyteStreamReader(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteStreamReader not supported; "
+raise LookupError(
+"MultibyteStreamReader not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
 
 class MultibyteStreamWriter(object):
 def __init__(self, *args, **kwds):
-raise NotImplementedError(
-"MultibyteStreamWriter not supported; "
+raise LookupError(
+"MultibyteStreamWriter not implemented; "
 "see pypy/module/_multibytecodec/app_multibytecodec.py")
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix the test by properly calling CODEC_INIT.

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44107:1a382602c9d6
Date: 2011-05-12 16:46 +0200
http://bitbucket.org/pypy/pypy/changeset/1a382602c9d6/

Log:Fix the test by properly calling CODEC_INIT.

diff --git a/pypy/translator/c/src/cjkcodecs/cjkcodecs.h 
b/pypy/translator/c/src/cjkcodecs/cjkcodecs.h
--- a/pypy/translator/c/src/cjkcodecs/cjkcodecs.h
+++ b/pypy/translator/c/src/cjkcodecs/cjkcodecs.h
@@ -209,11 +209,15 @@
 #define END_MAPPINGS_LIST /* empty */
 
 #define BEGIN_CODECS_LIST /* empty */
-#define _CODEC(name)\
-  static const MultibyteCodec _pypy_cjkcodec_##name;\
-  const MultibyteCodec *pypy_cjkcodec_##name(void) {\
-return &_pypy_cjkcodec_##name;  \
-  } \
+#define _CODEC(name)\
+  static const MultibyteCodec _pypy_cjkcodec_##name;\
+  const MultibyteCodec *pypy_cjkcodec_##name(void) {\
+if (_pypy_cjkcodec_##name.codecinit != NULL) {  \
+  int r = _pypy_cjkcodec_##name.codecinit(_pypy_cjkcodec_##name.config); \
+  assert(r == 0);   \
+}   \
+return &_pypy_cjkcodec_##name;  \
+  } \
   static const MultibyteCodec _pypy_cjkcodec_##name
 #define _STATEFUL_METHODS(enc)  \
 enc##_encode,   \
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: A failing test.

2011-05-12 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r44106:3d4c805a874e
Date: 2011-05-12 16:42 +0200
http://bitbucket.org/pypy/pypy/changeset/3d4c805a874e/

Log:A failing test.

diff --git a/pypy/module/_multibytecodec/test/test_c_codecs.py 
b/pypy/module/_multibytecodec/test/test_c_codecs.py
--- a/pypy/module/_multibytecodec/test/test_c_codecs.py
+++ b/pypy/module/_multibytecodec/test/test_c_codecs.py
@@ -50,3 +50,8 @@
 assert e.start == 3
 assert e.end == 4
 assert e.reason == "illegal multibyte sequence"
+
+def test_encode_jisx0208():
+c = getcodec('iso2022_jp')
+s = encode(c, u'\u83ca\u5730\u6642\u592b')
+assert s == '\x1b$B5FCO;~IW\x1b(B' and type(s) is str
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fixed up multibytecodec on windows. With much help from armin and amaury.

2011-05-12 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r44108:99f7b410912d
Date: 2011-05-12 15:27 -0400
http://bitbucket.org/pypy/pypy/changeset/99f7b410912d/

Log:Fixed up multibytecodec on windows. With much help from armin and
amaury.

diff --git a/pypy/module/_multibytecodec/c_codecs.py 
b/pypy/module/_multibytecodec/c_codecs.py
--- a/pypy/module/_multibytecodec/c_codecs.py
+++ b/pypy/module/_multibytecodec/c_codecs.py
@@ -18,28 +18,6 @@
 
 srcdir = py.path.local(pypydir).join('translator', 'c')
 
-eci = ExternalCompilationInfo(
-separate_module_files = [
-srcdir.join('src', 'cjkcodecs', '_codecs_cn.c'),
-srcdir.join('src', 'cjkcodecs', '_codecs_hk.c'),
-srcdir.join('src', 'cjkcodecs', '_codecs_iso2022.c'),
-srcdir.join('src', 'cjkcodecs', '_codecs_jp.c'),
-srcdir.join('src', 'cjkcodecs', '_codecs_kr.c'),
-srcdir.join('src', 'cjkcodecs', '_codecs_tw.c'),
-srcdir.join('src', 'cjkcodecs', 'multibytecodec.c'),
-],
-includes = ['src/cjkcodecs/multibytecodec.h'],
-include_dirs = [str(srcdir)],
-)
-
-MBERR_TOOSMALL = -1  # insufficient output buffer space
-MBERR_TOOFEW   = -2  # incomplete input buffer
-MBERR_INTERNAL = -3  # internal runtime error
-MBERR_NOMEMORY = -4  # out of memory
-
-MULTIBYTECODEC_P = rffi.COpaquePtr('struct MultibyteCodec_s',
-   compilation_info=eci)
-
 codecs = [
 # _codecs_cn
 'gb2312', 'gbk', 'gb18030', 'hz',
@@ -60,7 +38,38 @@
 
 # _codecs_tw
 'big5', 'cp950',
-]
+]
+
+eci = ExternalCompilationInfo(
+separate_module_files = [
+srcdir.join('src', 'cjkcodecs', '_codecs_cn.c'),
+srcdir.join('src', 'cjkcodecs', '_codecs_hk.c'),
+srcdir.join('src', 'cjkcodecs', '_codecs_iso2022.c'),
+srcdir.join('src', 'cjkcodecs', '_codecs_jp.c'),
+srcdir.join('src', 'cjkcodecs', '_codecs_kr.c'),
+srcdir.join('src', 'cjkcodecs', '_codecs_tw.c'),
+srcdir.join('src', 'cjkcodecs', 'multibytecodec.c'),
+],
+includes = ['src/cjkcodecs/multibytecodec.h'],
+include_dirs = [str(srcdir)],
+export_symbols = [
+"pypy_cjk_dec_init", "pypy_cjk_dec_free", "pypy_cjk_dec_chunk",
+"pypy_cjk_dec_outbuf", "pypy_cjk_dec_outlen",
+"pypy_cjk_dec_inbuf_remaining", "pypy_cjk_dec_inbuf_consumed",
+
+"pypy_cjk_enc_init", "pypy_cjk_enc_free", "pypy_cjk_enc_chunk",
+"pypy_cjk_enc_reset", "pypy_cjk_enc_outbuf", "pypy_cjk_enc_outlen",
+"pypy_cjk_enc_inbuf_remaining", "pypy_cjk_enc_inbuf_consumed",
+] + ["pypy_cjkcodec_%s" % codec for codec in codecs],
+)
+
+MBERR_TOOSMALL = -1  # insufficient output buffer space
+MBERR_TOOFEW   = -2  # incomplete input buffer
+MBERR_INTERNAL = -3  # internal runtime error
+MBERR_NOMEMORY = -4  # out of memory
+
+MULTIBYTECODEC_P = rffi.COpaquePtr('struct MultibyteCodec_s',
+   compilation_info=eci)
 
 def llexternal(*args, **kwds):
 kwds.setdefault('compilation_info', eci)
@@ -156,7 +165,6 @@
 
 # 
 # Encoding
-
 ENCODEBUF_P = rffi.COpaquePtr('struct pypy_cjk_enc_s', compilation_info=eci)
 pypy_cjk_enc_init = llexternal('pypy_cjk_enc_init',
[MULTIBYTECODEC_P, rffi.CWCHARP, rffi.SSIZE_T],
@@ -194,7 +202,7 @@
 assert False
 src = pypy_cjk_enc_outbuf(encodebuf)
 length = pypy_cjk_enc_outlen(encodebuf)
-return string_from_raw(src, length)
+return rffi.charpsize2str(src, length)
 #
 finally:
 pypy_cjk_enc_free(encodebuf)
@@ -220,18 +228,3 @@
 end = start + esize
 if 1:  # errors == ERROR_STRICT:
 raise EncodeDecodeError(start, end, reason)
-
-def string_from_raw(src, length):
-result = lltype.malloc(STR, length)
-try:
-str_chars_offset = (rffi.offsetof(STR, 'chars') + \
-rffi.itemoffsetof(STR.chars, 0))
-dest = rffi.cast_ptr_to_adr(result) + str_chars_offset
-src = rffi.cast_ptr_to_adr(src) + rffi.itemoffsetof(rffi.CCHARP.TO)
-rffi.raw_memcopy(src, dest,
- llmemory.sizeof(lltype.Char) * length)
-got = hlstr(result)
-finally:
-keepalive_until_here(result)
-assert got is not None
-return got
diff --git a/pypy/translator/c/src/cjkcodecs/multibytecodec.h 
b/pypy/translator/c/src/cjkcodecs/multibytecodec.h
--- a/pypy/translator/c/src/cjkcodecs/multibytecodec.h
+++ b/pypy/translator/c/src/cjkcodecs/multibytecodec.h
@@ -5,12 +5,27 @@
 
 #include 
 #include 
-#include 
 #include 
 
+#ifndef _WIN32
+#include 
+#endif
+
+#ifdef _WIN64
+typedef __int64 ssize_t
+#else
+#ifdef _WIN32
+typedef int ssize_t;
+#endif
+#endif
+
 #ifndef Py_UNICODE_SIZE
-#define Py_UNICODE_SIZE  4
-typedef uint32_t Py_UNICODE;
+#ifdef _WIN32
+#define Py_UNICODE_SIZE 2
+#else
+#define Py_UNICODE_SIZE 4
+#endif
+typedef wchar_t Py_UNICODE;
 typ

[pypy-commit] pypy default: (alex, arigato, mostly arigato) All tests pass in multibytecodec on windows.

2011-05-12 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r44109:7faa5a1b2a3b
Date: 2011-05-12 15:31 -0400
http://bitbucket.org/pypy/pypy/changeset/7faa5a1b2a3b/

Log:(alex, arigato, mostly arigato) All tests pass in multibytecodec on
windows.

diff --git a/pypy/module/_multibytecodec/test/test_translation.py 
b/pypy/module/_multibytecodec/test/test_translation.py
--- a/pypy/module/_multibytecodec/test/test_translation.py
+++ b/pypy/module/_multibytecodec/test/test_translation.py
@@ -1,3 +1,5 @@
+import sys
+
 from pypy.module._multibytecodec import c_codecs
 from pypy.translator.c.test import test_standalone
 
@@ -15,5 +17,9 @@
 return 0
 #
 t, cbuilder = self.compile(entry_point)
-data = cbuilder.cmdexec('hz \~\{abc\}')
+if sys.platform == "win32":
+cmd = 'hz "~{abc}"'
+else:
+cmd = 'hz \~\{abc\}'
+data = cbuilder.cmdexec(cmd)
 assert data == '~{abc}~}\n'
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Simplify, the windows quoting works on linux as well.

2011-05-12 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r44110:722e6f60cfc1
Date: 2011-05-12 15:45 -0400
http://bitbucket.org/pypy/pypy/changeset/722e6f60cfc1/

Log:Simplify, the windows quoting works on linux as well.

diff --git a/pypy/module/_multibytecodec/test/test_translation.py 
b/pypy/module/_multibytecodec/test/test_translation.py
--- a/pypy/module/_multibytecodec/test/test_translation.py
+++ b/pypy/module/_multibytecodec/test/test_translation.py
@@ -1,5 +1,3 @@
-import sys
-
 from pypy.module._multibytecodec import c_codecs
 from pypy.translator.c.test import test_standalone
 
@@ -17,9 +15,6 @@
 return 0
 #
 t, cbuilder = self.compile(entry_point)
-if sys.platform == "win32":
-cmd = 'hz "~{abc}"'
-else:
-cmd = 'hz \~\{abc\}'
+cmd = 'hz "~{abc}"'
 data = cbuilder.cmdexec(cmd)
 assert data == '~{abc}~}\n'
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: replace some more dead code, thanks amaury

2011-05-12 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r44111:d801f0b10219
Date: 2011-05-12 16:02 -0400
http://bitbucket.org/pypy/pypy/changeset/d801f0b10219/

Log:replace some more dead code, thanks amaury

diff --git a/pypy/module/_multibytecodec/c_codecs.py 
b/pypy/module/_multibytecodec/c_codecs.py
--- a/pypy/module/_multibytecodec/c_codecs.py
+++ b/pypy/module/_multibytecodec/c_codecs.py
@@ -1,8 +1,5 @@
 import py, sys
-from pypy.rpython.lltypesystem import lltype, llmemory, rffi
-from pypy.rpython.lltypesystem.rstr import STR, UNICODE
-from pypy.rpython.annlowlevel import hlstr, hlunicode
-from pypy.rlib.objectmodel import keepalive_until_here
+from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.tool.autopath import pypydir
 
@@ -121,7 +118,7 @@
 assert False
 src = pypy_cjk_dec_outbuf(decodebuf)
 length = pypy_cjk_dec_outlen(decodebuf)
-return unicode_from_raw(src, length)
+return rffi.wcharpsize2unicode(src, length)
 #
 finally:
 pypy_cjk_dec_free(decodebuf)
@@ -148,21 +145,6 @@
 if 1:  # errors == ERROR_STRICT:
 raise EncodeDecodeError(start, end, reason)
 
-def unicode_from_raw(src, length):
-result = lltype.malloc(UNICODE, length)
-try:
-uni_chars_offset = (rffi.offsetof(UNICODE, 'chars') + \
-rffi.itemoffsetof(UNICODE.chars, 0))
-dest = rffi.cast_ptr_to_adr(result) + uni_chars_offset
-src = rffi.cast_ptr_to_adr(src) + rffi.itemoffsetof(rffi.CWCHARP.TO)
-rffi.raw_memcopy(src, dest,
- llmemory.sizeof(lltype.UniChar) * length)
-got = hlunicode(result)
-finally:
-keepalive_until_here(result)
-assert got is not None
-return got
-
 # 
 # Encoding
 ENCODEBUF_P = rffi.COpaquePtr('struct pypy_cjk_enc_s', compilation_info=eci)
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: (alex, arigato, amaury) Switch the rffi functions which convert a char* to a str to use {String, Unicode}Builder to avoid copies most of the time.

2011-05-12 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r44112:18429152eefe
Date: 2011-05-12 16:27 -0400
http://bitbucket.org/pypy/pypy/changeset/18429152eefe/

Log:(alex, arigato, amaury) Switch the rffi functions which convert a
char* to a str to use {String,Unicode}Builder to avoid copies most
of the time.

diff --git a/pypy/rpython/lltypesystem/rffi.py 
b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -15,6 +15,7 @@
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.rpython.annlowlevel import llhelper
 from pypy.rlib.objectmodel import we_are_translated
+from pypy.rlib.rstring import StringBuilder, UnicodeBuilder
 from pypy.rpython.lltypesystem import llmemory
 import os, sys
 
@@ -538,7 +539,7 @@
 val = rffi_platform.sizeof(name, compilation_info)
 cache[name] = val
 return val
-
+
 hints['getsize'] = lazy_getsize
 return lltype.OpaqueType(name, hints)
 
@@ -636,24 +637,24 @@
 # conversions between str and char*
 # conversions between unicode and wchar_t*
 def make_string_mappings(strtype):
-
+
 if strtype is str:
 from pypy.rpython.lltypesystem.rstr import STR as STRTYPE
 from pypy.rpython.annlowlevel import llstr as llstrtype
 from pypy.rpython.annlowlevel import hlstr as hlstrtype
 TYPEP = CCHARP
 ll_char_type = lltype.Char
-emptystr = ''
 lastchar = '\x00'
+builder_class = StringBuilder
 else:
 from pypy.rpython.lltypesystem.rstr import UNICODE as STRTYPE
 from pypy.rpython.annlowlevel import llunicode as llstrtype
 from pypy.rpython.annlowlevel import hlunicode as hlstrtype
 TYPEP = CWCHARP
 ll_char_type = lltype.UniChar
-emptystr = u''
 lastchar = u'\x00'
-
+builder_class = UnicodeBuilder
+
 # str -> char*
 def str2charp(s):
 """ str -> char*
@@ -674,12 +675,12 @@
 # char* -> str
 # doesn't free char*
 def charp2str(cp):
-l = []
+b = builder_class()
 i = 0
 while cp[i] != lastchar:
-l.append(cp[i])
+b.append(cp[i])
 i += 1
-return emptystr.join(l)
+return b.build()
 
 # str -> char*
 def get_nonmovingbuffer(data):
@@ -777,17 +778,19 @@
 
 # char* -> str, with an upper bound on the length in case there is no \x00
 def charp2strn(cp, maxlen):
-l = []
+b = builder_class(maxlen)
 i = 0
 while i < maxlen and cp[i] != lastchar:
-l.append(cp[i])
+b.append(cp[i])
 i += 1
-return emptystr.join(l)
+return b.build()
 
 # char* and size -> str (which can contain null bytes)
 def charpsize2str(cp, size):
-l = [cp[i] for i in range(size)]
-return emptystr.join(l)
+b = builder_class(size)
+for i in xrange(size):
+b.append(cp[i])
+return b.build()
 charpsize2str._annenforceargs_ = [None, int]
 
 return (str2charp, free_charp, charp2str,
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Allow the JIT to inline into posix. These are mostly wrappers around low level functions, and it's silly to force the caches to be cleared because of those calls, as well a

2011-05-12 Thread alex_gaynor
Author: Alex Gaynor 
Branch: 
Changeset: r44113:2cf2bc2ec94a
Date: 2011-05-12 22:14 -0400
http://bitbucket.org/pypy/pypy/changeset/2cf2bc2ec94a/

Log:Allow the JIT to inline into posix. These are mostly wrappers around
low level functions, and it's silly to force the caches to be
cleared because of those calls, as well as the extra
wrapping/allocation of W_ objects.

diff --git a/pypy/module/pypyjit/policy.py b/pypy/module/pypyjit/policy.py
--- a/pypy/module/pypyjit/policy.py
+++ b/pypy/module/pypyjit/policy.py
@@ -14,7 +14,7 @@
 modname, _ = modname.split('.', 1)
 if modname in ['pypyjit', 'signal', 'micronumpy', 'math', 'exceptions',
'imp', 'sys', 'array', '_ffi', 'itertools', 'operator',
-   '_socket', '_sre', '_lsprof']:
+   'posix', '_socket', '_sre', '_lsprof']:
 return True
 return False
 
___
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit