Posts: 4,560
Threads: 1,464
Joined: Sep 2016
a feature i would like to see added to Python in some future version is the ability to add methods to a builtin class and have it be automatically available to all instances and derived classes.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,560
Threads: 1,464
Joined: Sep 2016
Sep-28-2018, 12:08 AM
(This post was last modified: Sep-28-2018, 12:09 AM by Skaperen.)
yes, overriding. but i'm not talking about merely doing it in an inherited class. i'm talking about retroactively applying it to an existing class with existing instances and classes inheriting from it. and i am also talking about doing this with builtin primitive classes, such as int.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,560
Threads: 1,464
Joined: Sep 2016
yes, it would be slower. if i want speed, i'll use C (and i know C quite well). actually, i have run across many cases where i wanted to change (for that program) some existing logic.
maybe a better way would be to freeze the internal API at the major version level and allow binary modules to be loaded to hook in to internal methods. Apache has done this. my idea for a new language from many years ago was a 2 level language where there was a nearly C-like lower level and a nearly Python-like upper level (without Python's syntax which i am wanting to retrofit to both levels). maybe doing that would be better than trying to change Python (since there seems to be substantial resistance to any changes).
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,560
Threads: 1,464
Joined: Sep 2016
so if i write some code that adds a method to a bultin type, assuming that could be done, and uses it in that code,that would be considered monkey patching?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.