[Python-ideas] More alternate constructors for builtin type

Antoine Pitrou solipsis at pitrou.net
Mon May 6 12:47:39 EDT 2019


On Mon, 6 May 2019 19:39:39 +0300
Serge Matveenko <s at matveenko.ru> wrote:
> On Mon, May 6, 2019 at 7:29 PM Guido van Rossum <guido at python.org> wrote:
> >
> > On Mon, May 6, 2019 at 11:14 AM Serhiy Storchaka <storchaka at gmail.com> wrote:  
> >> I do not propose to change the current behavior. I propose to add new
> >> named constructors. In most cases default constructors can be used, but
> >> in cases when we use type check or different tricks to limit the type of
> >> the argument, we could use named constructors.
> >>
> >> Current named constructors:
> >>
> >> * dict.fromkeys()
> >> * int.from_bytes()
> >> * float.fromhex()
> >> * bytes.fromhex()
> >> * bytearray.fromhex()  
> >
> >
> > Understood. My point is that we won't be able to remove the original behavior, so we'd end up with two ways to do it. :-(  
> 
> With all respect, I disagree. There are ways to evolve Python such as
> deprecation policies which proven to be effective. There are ways to
> monitor current features adoption on PyPI to see whether it is safe to
> remove deprecated things.

The main constructors for built-in types are used so pervasively that
there is no hope of actually removing such deprecated behavior.

Regards

Antoine.




More information about the Python-ideas mailing list