[issue44977] Deprecate delegation of int to __trunc__

2022-02-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Thanks Zackery. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue44977] Deprecate delegation of int to __trunc__

2022-02-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset b4bd1e1422997de61faf506b4916e83013bc7d21 by Zackery Spytz in branch 'main': bpo-44977: Deprecate delegation of int to __trunc__ (GH-31031) https://github.com/python/cpython/commit/b4bd1e1422997de61faf506b4916e83013bc7d21 --

[issue44977] Deprecate delegation of int to __trunc__

2022-01-30 Thread Zackery Spytz
Zackery Spytz added the comment: I have created a patch for this issue. Please consider having a look. -- ___ Python tracker ___ _

[issue44977] Deprecate delegation of int to __trunc__

2022-01-30 Thread Zackery Spytz
Change by Zackery Spytz : -- keywords: +patch nosy: +ZackerySpytz nosy_count: 3.0 -> 4.0 pull_requests: +29214 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/31031 ___ Python tracker

[issue44977] Deprecate delegation of int to __trunc__

2021-10-15 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- components: +Interpreter Core stage: -> needs patch title: Deprecate delegation of int to __trunc__? -> Deprecate delegation of int to __trunc__ versions: +Python 3.11 ___ Python tracker

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: I retract the suggestion to deprecate __trunc__. -- ___ Python tracker ___ ___ Python-bugs-lis

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Mark Dickinson
Mark Dickinson added the comment: I think the needs are sufficiently different that __trunc__ still has value as its own thing, and it's a natural counterpart to __floor__ and __ceil__ (out of all the directed rounding modes, rounding towards zero probably turns up more often than rounding t

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I do not think that math.trunc() for UUID or IP4Address makes sense. -- ___ Python tracker ___

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: Possibly, we could have math.trunc() call __int__, letting us deprecate __trunc__. That would let users avoid gratuitous aliasing such as that in _pydecimal.py: __trunc__ = __int__ -- ___ Python tracker

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Mark Dickinson
Mark Dickinson added the comment: A GitHub code search shows a substantial number of uses of math.trunc out in the wild: https://github.com/search?q=math.trunc+extension%3Apy&type=Code So unfortunately, getting rid of math.trunc and __trunc__ looks a bit too much as though it would cause gr

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Raymond Hettinger
Raymond Hettinger added the comment: Afterwards, do __trunc__ and math.trunc() still need to exist? They were mostly unused. Now they would also be unnecessary. Just having them around would be a point of confusion. -- nosy: +rhettinger ___ Pyth

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Completely agree. -- nosy: +serhiy.storchaka ___ Python tracker ___ ___ Python-bugs-list mailin

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Mark Dickinson
Mark Dickinson added the comment: > This decouples int from __trunc__ and leaves __trunc__ as simply the support > for the math.trunc function. Argh; copy and paste fail - I left out the crucial line. I propose deprecating the delegation of int to __trunc__: calls to int(a) where type(a) im

[issue44977] Deprecate delegation of int to __trunc__?

2021-08-22 Thread Mark Dickinson
New submission from Mark Dickinson : The int constructor, when applied to a general Python object `obj`, first looks for an __int__ method, then for an __index__ method, and then finally for a __trunc__ method. The delegation to __trunc__ used to be useful: it meant that users could write a