cython icon indicating copy to clipboard operation
cython copied to clipboard

Add unbounded pointer depth in pure Python 3.7+

Open kne42 opened this issue 7 years ago • 7 comments

Leverages module-level __getattr__ as introduced in PEP 562 (Python 3.7+) to enable unbounded depth on pointers in interpreted Python based on their names; i.e. from cython import ppppppp_int will now be valid.

kne42 avatar Aug 22 '18 21:08 kne42

BTW, the fact that travis is unhappy is unrelated to this PR. Would be nice if you could rebase it on latest master.

scoder avatar Aug 25 '18 10:08 scoder

Any update on this?

scoder avatar Aug 31 '18 08:08 scoder

@scoder I have been on holiday for the past two weeks with limited access to my laptop and wifi. I will update the PR as soon as I get back.

In the meantime, I think this should come with a test as well. I presume that this fits best under tests/run, correct?

On Fri, Aug 31, 2018 at 10:29 scoder [email protected] wrote:

Any update on this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/cython/cython/pull/2571#issuecomment-417592068, or mute the thread https://github.com/notifications/unsubscribe-auth/Ab0F0zKTZeKbUOAkg1Thw8DUJKGJxGP6ks5uWPPUgaJpZM4WIbNO .

kne42 avatar Aug 31 '18 08:08 kne42

All fine, no rush, just wanted to check back. Yep, runnable tests go into tests/run/. Specifically, the pure* tests would be relevant examples here since they are executed in both Cython and Python. You can exclude older Python versions from running the pure Python tests by adding a pure3.7 tag at the top, which also suggests that this would best be a test on its own, just name it pure_py37.py then.

scoder avatar Aug 31 '18 09:08 scoder

@scoder I'll try looking into it. Can you give me some guidance on the work thats already done and what needs to be done. I would be really thankful. 👍

HSR05 avatar Mar 19 '19 04:03 HSR05

Instead of using lru_cache, you could just add the constructed pointers to the global namespace. That way future lookups will grab the new attribute and bypass __getattr__ entirely.

TeamSpen210 avatar Mar 21 '19 03:03 TeamSpen210

@TeamSpen210, sounds good. @HSR05, the test needs fixing and the implementation should work with Py2.7.

scoder avatar Mar 24 '19 15:03 scoder