implementing properties in user modules

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
User avatar
jimmo
Posts: 1440
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: implementing properties in user modules

Post by jimmo » Sat Feb 15, 2020 12:54 pm

v923z wrote:
Sat Feb 15, 2020 12:15 pm
OK, so you are, in principle, willing to accept changes to the micropython core.
Just to be clear -- this is just my suggestion as someone who spends a moderate amount of time spelunking in the core (but without any actual authority or ability to accept changes).

v923z
Posts: 117
Joined: Mon Dec 28, 2015 6:19 pm

Re: implementing properties in user modules

Post by v923z » Sat Feb 15, 2020 4:08 pm

jimmo wrote:
Sat Feb 15, 2020 12:54 pm
v923z wrote:
Sat Feb 15, 2020 12:15 pm
OK, so you are, in principle, willing to accept changes to the micropython core.
Just to be clear -- this is just my suggestion as someone who spends a moderate amount of time spelunking in the core (but without any actual authority or ability to accept changes).
Don't worry, I didn't take your earlier comment as an outright promise.

v923z
Posts: 117
Joined: Mon Dec 28, 2015 6:19 pm

Re: implementing properties in user modules

Post by v923z » Sat Feb 15, 2020 6:55 pm

jimmo wrote:
Sat Feb 15, 2020 12:54 pm
v923z wrote:
Sat Feb 15, 2020 12:15 pm
OK, so you are, in principle, willing to accept changes to the micropython core.
Just to be clear -- this is just my suggestion as someone who spends a moderate amount of time spelunking in the core (but without any actual authority or ability to accept changes).
For future reference: without losing sight of your comment, I have created a pull request with the necessary changes: https://github.com/micropython/micropython/pull/5648

And you were right, lifting code verbatim from circuitpython's runtime.c fixes the issue.

stijn
Posts: 429
Joined: Thu Apr 24, 2014 9:13 am

Re: implementing properties in user modules

Post by stijn » Sat Feb 15, 2020 7:18 pm

v923z wrote:
Sat Feb 15, 2020 9:10 am
That overrides the locals dictionary, so nothing defined in the locals will be available as a class method.
Yup, forgot we use a custom attr function which does all of that, i.e. first lookup locals dict then property getters etc

v923z
Posts: 117
Joined: Mon Dec 28, 2015 6:19 pm

Re: implementing properties in user modules

Post by v923z » Sat Feb 15, 2020 7:24 pm

stijn wrote:
Sat Feb 15, 2020 7:18 pm
v923z wrote:
Sat Feb 15, 2020 9:10 am
That overrides the locals dictionary, so nothing defined in the locals will be available as a class method.
Yup, forgot we use a custom attr function which does all of that, i.e. first lookup locals dict then property getters etc
Just curious: who is "we"? You did exactly what Jim's suggested earlier, right?

stijn
Posts: 429
Joined: Thu Apr 24, 2014 9:13 am

Re: implementing properties in user modules

Post by stijn » Sat Feb 15, 2020 8:08 pm

Talking about https://github.com/stinos/micropython-w ... per.h#L372 bascially. With 'we' I meant 'me and colleagues' but actually I wrote all of it so on second thought: yes would be less confusing to just say 'I' :D

v923z
Posts: 117
Joined: Mon Dec 28, 2015 6:19 pm

Re: implementing properties in user modules

Post by v923z » Sun Feb 16, 2020 3:11 pm

stijn wrote:
Sat Feb 15, 2020 8:08 pm
Talking about https://github.com/stinos/micropython-w ... per.h#L372 bascially. With 'we' I meant 'me and colleagues' but actually I wrote all of it so on second thought: yes would be less confusing to just say 'I' :D
Sorry, I wasn't nit-picking, I was simply curious. This wrapper project of yours is really interesting.

stijn
Posts: 429
Joined: Thu Apr 24, 2014 9:13 am

Re: implementing properties in user modules

Post by stijn » Mon Feb 17, 2020 9:03 am

Oh no problem I didn't treat it as nit-picking, I genuinely think saying 'we' is confusing because it doesn't convey any meaning to others.
This wrapper project of yours is really interesting.
Thanks! It didn't completely turn out the way I wanted but if you have to wrap hundreds of functions/classes it's quite the timesaver

Post Reply