[Python-Dev] trunc()

Paul Moore p.f.moore at gmail.com
Fri Jan 25 14:53:15 CET 2008


On 24/01/2008, Jeffrey Yasskin <jyasskin at gmail.com> wrote:
> int has to be a builtin because it's a fundamental type. trunc()
> followed round() into the builtins. I have no opinion on whether ceil
> and floor should move there; it probably depends on how often they're
> used.

Suggestion:

- int() has to stay in builtins for obvious reasons.
- put *all* of trunc, ceil, floor, round into math.
- make int(float) an error

The only fly in the ointment is that 2to3 can't handle the semantic
issues around converting int(n) to math.trunc(n) because it can't
detect the type of n. So why not make int(float) warn in -3 mode on
2.6, and then let 2to3 do the conversion (on the basis that 2to3
should only be run on code that is -3 warning free)?

Did I miss a requirement here?

Paul.


More information about the Python-Dev mailing list