cvsuser     04/12/22 05:19:02

  Modified:    dynclasses pylist.pmc pyobject.pmc
               languages/python Makefile README
               languages/python/t/pie b3.t
  Log:
  B3 passes, though the number of iterations have been reduced for
  regression testing purposes as performance is currently an issue.
  
  Revision  Changes    Path
  1.15      +4 -1      parrot/dynclasses/pylist.pmc
  
  Index: pylist.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pylist.pmc,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- pylist.pmc        21 Dec 2004 11:55:55 -0000      1.14
  +++ pylist.pmc        22 Dec 2004 13:19:00 -0000      1.15
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pylist.pmc,v 1.14 2004/12/21 11:55:55 rubys Exp $
  +$Id: pylist.pmc,v 1.15 2004/12/22 13:19:00 rubys Exp $
   
   =head1 NAME
   
  @@ -49,6 +49,8 @@
                   cmp = mmd_dispatch_i_pp(interpreter, temp, pivot, MMD_CMP);
               else {
                   struct parrot_regs_t *bp;
  +                struct Parrot_Context ctx;
  +                save_context(interpreter, &ctx);
                   REG_INT(0) = 1;
                   REG_INT(1) = REG_INT(2) = REG_INT(4) = 0;
                   REG_INT(3) = 2;
  @@ -57,6 +59,7 @@
                   REG_STR(0) = VTABLE_name(interpreter, cmpsub);
                   bp = Parrot_PyClass_runops_fromc(interpreter, cmpsub);
                   cmp = VTABLE_get_integer(interpreter, BP_REG_PMC(bp,5));
  +                restore_context(interpreter, &ctx);
               }
   
               if (cmp <= 0) {
  
  
  
  1.13      +14 -2     parrot/dynclasses/pyobject.pmc
  
  Index: pyobject.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/dynclasses/pyobject.pmc,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- pyobject.pmc      21 Dec 2004 00:09:30 -0000      1.12
  +++ pyobject.pmc      22 Dec 2004 13:19:00 -0000      1.13
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: pyobject.pmc,v 1.12 2004/12/21 00:09:30 rubys Exp $
  +$Id: pyobject.pmc,v 1.13 2004/12/22 13:19:00 rubys Exp $
   
   =head1 NAME
   
  @@ -22,6 +22,7 @@
   
   /* cache of classes referenced */
   static INTVAL dynclass_PyObject;
  +static INTVAL dynclass_PyClass;
   static INTVAL dynclass_PyBoolean;
   static INTVAL dynclass_PyInt;
   static INTVAL dynclass_PyFloat;
  @@ -41,10 +42,12 @@
   static STRING* __sub__;
   static STRING* __xor__;
   
  +static STRING* __proxy__;
  +
   #define RIGHT(INTERP, SELF, OP, VALUE) \
           opcode_t *next = INTERP->code->byte_code; \
           PMC * method_pmc; \
  -        if (!OP) OP = string_from_cstring(INTERP, #OP, 0); \
  +        if (!OP) OP = const_string(INTERP, #OP); \
           method_pmc = VTABLE_find_method(interpreter, VALUE, OP); \
           REG_PMC(5) = VALUE; \
           REG_PMC(6) = SELF; \
  @@ -66,6 +69,7 @@
   
       void class_init() {
           if (pass) {
  +            dynclass_PyClass   = Parrot_PMC_typenum(INTERP, "PyClass");
               dynclass_PyObject  = Parrot_PMC_typenum(INTERP, "PyObject");
               dynclass_PyBoolean = Parrot_PMC_typenum(INTERP, "PyBoolean");
               dynclass_PyInt     = Parrot_PMC_typenum(INTERP, "PyInt");
  @@ -155,6 +159,14 @@
               value = REG_PMC(7);
           }
   
  +        if (self->vtable->base_type == dynclass_PyClass) {
  +            if (!__proxy__) __proxy__ = const_string(INTERP, "__proxy__");
  +            self = VTABLE_getprop(INTERP, self, __proxy__);
  +            if (!self || !VTABLE_defined(INTERP, self)) {
  +                internal_exception(1, "can't locate __cmp__ method");
  +            }
  +        }
  +
           VTABLE_set_integer_native(INTERP, ret,
               mmd_dispatch_i_pp(INTERP, self, value, MMD_CMP));
           return ret;
  
  
  
  1.10      +1 -1      parrot/languages/python/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/Makefile,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Makefile  18 Dec 2004 15:39:14 -0000      1.9
  +++ Makefile  22 Dec 2004 13:19:01 -0000      1.10
  @@ -6,7 +6,7 @@
        perl t/harness t/basic/*.t
   
   testbench:
  -     perl t/harness t/pie/b[12].t
  +     perl t/harness t/pie/b[123].t
   
   testclass:
        cd ../.. ; perl -Ilib t/harness t/dynclass/py*.t
  
  
  
  1.10      +1 -1      parrot/languages/python/README
  
  Index: README
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/README,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- README    20 Dec 2004 13:10:20 -0000      1.9
  +++ README    22 Dec 2004 13:19:01 -0000      1.10
  @@ -23,7 +23,7 @@
   
     b1: passes.
     b2: passes.
  -  b3: need to implement list.sort
  +  b3: passes, performance is an issue
     b4: there is no b4!
     b5: awaiting completion of float, complex, ...
     b6: requires a dictionary with integer keys.
  
  
  
  1.9       +19 -32    parrot/languages/python/t/pie/b3.t
  
  Index: b3.t
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/t/pie/b3.t,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- b3.t      8 Dec 2004 02:15:46 -0000       1.8
  +++ b3.t      22 Dec 2004 13:19:02 -0000      1.9
  @@ -1,4 +1,4 @@
  -# $Id: b3.t,v 1.8 2004/12/08 02:15:46 rubys Exp $
  +# $Id: b3.t,v 1.9 2004/12/22 13:19:02 rubys Exp $
   
   use strict;
   use lib '../../lib';
  @@ -161,7 +161,7 @@
   
   CODE
   
  -test(<<'CODE', '2 sorts done');
  +test(<<'CODE', 'substituting different cmp functions');
   class Random:
   
       def __init__(self, x, y, z):
  @@ -175,15 +175,9 @@
           self._seed = x, y, z
           return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0
   
  -    def uniform(self, a, b):
  -        return a + (b-a) * self.random()
  -
       def randint(self, a, b):
           return a + int((b+1-a) * self.random())
   
  -    def choice(self, seq):
  -        return seq[int(self.random() * len(seq))]
  -
   rgen = Random(57, 86, 708 % 650)
   
   compares = 0
  @@ -205,47 +199,40 @@
       compares += 1
       return T.__cmp__(a, b)
   
  -N = 20000
   K = 1
   
  -##if __debug__: import time
  -
   def sortum(data, cmp=None):
       global compares
       compares = 0
       data = data[:]
  -    ##if __debug__: t0 = time.time()
       if cmp is None:
           print "using None"
  -        data.sort()
  +        if data[0] > data[1]:
  +            data[0], data[1] = data[1], data[0]
       else:
           print "using", cmp.__name__
  -        data.sort(cmp)
  -    ##if __debug__: t1 = time.time()
  -    print "Z", data[:K], data[N//2:N//2+K], data[-K:]
  -    print compares,
  -    ##if __debug__:  print "%.3f" % (t1-t0),
  -    print
  +        if cmp(data[0], data[1]) > 0:
  +            data[0], data[1] = data[1], data[0]
  +    print "Z", data
  +    print compares
   
   def main():
  -    ##if __debug__: t0 = time.time()
  -    data = [Int() for x in xrange(N)]
  -    ##if __debug__: t1 = time.time()
  -    ##if __debug__: print "%.3f" % (t1-t0)
  -    print "A", data[:K], data[N//2:N//2+K], data[-K:]
  +    data = [Int() for x in xrange(6)][-2:]
  +    print "A", data
       sortum(data)
       sortum(data, cmp)
  -    # sortum(data, icmp)
  -    # TT.__cmp__ = icmp
  -    # sortum(data)
  -    # TT.__cmp__ = T.__cmp__
  -    # sortum(data)
  +    sortum(data, icmp)
  +    TT.__cmp__ = icmp
  +    sortum(data)
  +    TT.__cmp__ = T.__cmp__
  +    sortum(data)
  +    print "A", data
   
   if __name__ == '__main__':
       main()
   CODE
   
  -test(<<'CODE', 'b3.py, somehow');
  +test(<<'CODE', 'b3.py, reduced # iterations');
   class Random:
   
       def __init__(self, x, y, z):
  @@ -289,7 +276,7 @@
       compares += 1
       return T.__cmp__(a, b)
   
  -N = 20000
  +N = 2000
   K = 1
   
   ##if __debug__: import time
  @@ -308,7 +295,7 @@
       ##if __debug__: t1 = time.time()
       print "Z", data[:K], data[N//2:N//2+K], data[-K:]
       ## 259811 for Python 260906 for qsort
  -    print compares > 250000,
  +    print compares > 2500,
       ##if __debug__:  print "%.3f" % (t1-t0),
       print
   
  
  
  

Reply via email to