Is the PEP238 change to division going into Python 3 as planned?\n\nI realise that the new integer division semantics have been available\nin "from __future__" for quite a few years now, but a warning might be\nappropriate now that Python 3 is in alpha. A lot of people have\nprobably either forgotten, or else never knew about PEP238. The\nfollowing wording is still included in the Python 2.5.1\ndocumentation...\n\n"""\n3.1.1 Numbers\nThe interpreter acts as a simple calculator: you can type an\nexpression at it and it will write the value. Expression syntax is\nstraightforward: the operators +, -, * and / work just like in most\nother languages (for example, Pascal or C); parentheses can be used\nfor grouping. For example:\n\n.... 2+2\n4.... 7/3\n2-3\n"""\n\nWhich is interesting, since neither Pascal nor C division works like\nthat. Pascal has a separate 'div' operator for integer division. C and\nC++ compilers usually round toward zero IIRC, but the rounding\ndirection is not defined in the standards. In any case, after the\nfinal adoption of PEP238, integer division in Python will generally\nreturn float results - not the rounded-to-floor integer results shown\nhere.\n\nIt might be worth brainstorming some contexts where problems are\nlikely to occur, to help anyone trying to prepare for the change.\n\nMy contribution to that would be any code that needs to partition\nlists into slices. The obvious cases - binary searching, sorting - are\ncovered by libraries which should be used in preference to hand-\nwritten code, but this kind of thing can happen elsewhere. I have some\ncode that organises a sorted list of data into a balanced tree as part\nof a code generation task, for example, which relies on floor\ndivision.\n\nAlso, if money amounts are stored as integer numbers of pennies (which\nthey often are, since floats represent approximate values) problems\ncould occur with various calculations since multiplication by a\nfractional quantity is often represented as a multiplication followed\nby a division. For example adding 5% is equivalent to multiplying by\n1.05, or to multiplying by 105 then dividing by 100. The latter idiom\nis often used to keep everything integer, which requires division\nresults to be rounded.\n\nUse of the decimal module is probably a good idea for money amounts\nthese days, of course. I've not used it myself but the whole point of\na decimal number type would be to get exact results and the kind of\nrounding behaviour that accountants would expect.\n\nThe real world fix would normally be to replace the / operator\nwith //, though, in order to keep the old floor-division semantics.