[Python-checkins] CVS: python/dist/src/Parser tokenizer.c,2.50,2.51
Guido van Rossum
gvanrossum@users.sourceforge.net
Tue, 07 Aug 2001 22:00:20 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Include abstract.h,2.35,2.36 compile.h,2.33,2.34 object.h,2.82,2.83 opcode.h,2.36,2.37 pythonrun.h,2.44,2.45 token.h,2.18,2.19
- Next message: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.70,2.71 classobject.c,2.134,2.135 complexobject.c,2.36,2.37 floatobject.c,2.84,2.85 intobject.c,2.60,2.61 longobject.c,1.90,1.91
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Parser
In directory usw-pr-cvs1:/tmp/cvs-serv23513/Parser
Modified Files:
tokenizer.c
Log Message:
Implement PEP 238 in its (almost) full glory.
This introduces:
- A new operator // that means floor division (the kind of division
where 1/2 is 0).
- The "future division" statement ("from __future__ import division)
which changes the meaning of the / operator to implement "true
division" (where 1/2 is 0.5).
- New overloadable operators __truediv__ and __floordiv__.
- New slots in the PyNumberMethods struct for true and floor division,
new abstract APIs for them, new opcodes, and so on.
I emphasize that without the future division statement, the semantics
of / will remain unchanged until Python 3.0.
Not yet implemented are warnings (default off) when / is used with int
or long arguments.
This has been on display since 7/31 as SF patch #443474.
Flames to /dev/null.
Index: tokenizer.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v
retrieving revision 2.50
retrieving revision 2.51
diff -C2 -d -r2.50 -r2.51
*** tokenizer.c 2001/04/21 02:46:11 2.50
--- tokenizer.c 2001/08/08 05:00:18 2.51
***************
*** 81,84 ****
--- 81,86 ----
"RIGHTSHIFTEQUAL",
"DOUBLESTAREQUAL",
+ "DOUBLESLASH",
+ "DOUBLESLASHEQUAL",
/* This table must match the #defines in token.h! */
"OP",
***************
*** 409,412 ****
--- 411,415 ----
case '/':
switch (c2) {
+ case '/': return DOUBLESLASH;
case '=': return SLASHEQUAL;
}
***************
*** 466,469 ****
--- 469,482 ----
case '=':
return DOUBLESTAREQUAL;
+ }
+ break;
+ }
+ break;
+ case '/':
+ switch (c2) {
+ case '/':
+ switch (c3) {
+ case '=':
+ return DOUBLESLASHEQUAL;
}
break;
- Previous message: [Python-checkins] CVS: python/dist/src/Include abstract.h,2.35,2.36 compile.h,2.33,2.34 object.h,2.82,2.83 opcode.h,2.36,2.37 pythonrun.h,2.44,2.45 token.h,2.18,2.19
- Next message: [Python-checkins] CVS: python/dist/src/Objects abstract.c,2.70,2.71 classobject.c,2.134,2.135 complexobject.c,2.36,2.37 floatobject.c,2.84,2.85 intobject.c,2.60,2.61 longobject.c,1.90,1.91
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]