Skip to content

add complex class test#143

Open
mw66 wants to merge 10 commits into
ariovistus:masterfrom
mw66:new_branch
Open

add complex class test#143
mw66 wants to merge 10 commits into
ariovistus:masterfrom
mw66:new_branch

Conversation

@mw66

@mw66 mw66 commented Dec 19, 2020

Copy link
Copy Markdown
Contributor

This is a bug report actually:

$ cat c.py

c = complex(2,-1)
h = c.__hash__();

print(c)
print(h)

# python output
$ python c.py 
(2-1j)
-2000004   # here!

however, pyd output:

$ dub build
$ ./simple_embedded 
1 + 2
(2-1j)
<method-wrapper '__hash__' of complex object at 0x7fa8c49897d0>  # here!

@mw66

mw66 commented Dec 19, 2020

Copy link
Copy Markdown
Contributor Author

I just found the work around how to make the pyd call:

    auto h = c.__hash__()();

I think here we should use the python convention:

  c.__hash__;    // return the method-wrapper
  c.__hash__();  // return the result of the function call.

@ariovistus

Copy link
Copy Markdown
Owner

Ah, yeah, that's kind of annoying. I would certainly like it if I could get D to do as you suggest, but there is no way (or wasn't last time I checked, admittedly a while) to get opDispatch to distinguish between obj.property and obj.property(). So we have this kind of compromise where no parameters are treated as obj.property and presence of parameters are treated as a method call.

@mw66

mw66 commented Dec 20, 2020

Copy link
Copy Markdown
Contributor Author

OK, I added the work-around, so new user can follow the example to make the call.

@mw66

mw66 commented Mar 10, 2022

Copy link
Copy Markdown
Contributor Author

@ariovistus: I'm a git idiot, I tried to add python39 support (which I have been used for a year without problem on my local machine), but I messed up my PR and my local branches.

It should be just a single file PR (commit hash 170ac4b) for dub.json:

170ac4b

If you have time, can you separate this file as a single PR and merge it, then we can have python39 support.

Thanks.

@ariovistus

Copy link
Copy Markdown
Owner

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants