Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimized hasproperty(o::Py, attr) = pyhasattr(o, attr) #157

Closed
stevengj opened this issue Apr 14, 2022 · 1 comment
Closed

optimized hasproperty(o::Py, attr) = pyhasattr(o, attr) #157

stevengj opened this issue Apr 14, 2022 · 1 comment

Comments

@stevengj
Copy link
Member

stevengj commented Apr 14, 2022

Currently, hasproperty(o, attr) works by falling back to Julia's default method, which checks attr in propertynames(o). This is functional but rather inefficient because it first constructs the propertynames list.

Since you already have an optimized pyhasattr method, it seems like you should just define:

hasproperty(o::Py, attr::Symbol) = hasproperty(o, String(attr))
hasproperty(o::Py, attr::AbstractString) = pyhasattr(o, attr)
@cjdoris
Copy link
Collaborator

cjdoris commented Apr 21, 2022

Good idea, this is more consistent with getproperty and setproperty. Done.

@cjdoris cjdoris closed this as completed Apr 21, 2022
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

No branches or pull requests

2 participants