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
[python] _swigconstant helpers needlessly generated for primitive types #563
Comments
FWIW for now I have worked around by not using swig3.0 and relying on swig2.0 in Debian so the problem is not that "pressing" |
Can you provide a small, self-contained example and explain exactly what the problem with the code generated by the latest version is? Please also include the SWIG command line to process the file. |
here is not quite a minimal but quite verbatim and complete as working for me on a Debian testing/sid:
|
any other information I could provide to point toward proper resolution? |
Yes, I don't understand what the actual problem is, can you elaborate what is broken or not working etc. |
Actually, having just looked at updating Xapian's Python bindings to use the latest SWIG, I think I now have some understanding of this issue. In 3.0.5, there was a change to make
And the However, the conditions under which the new machinery gets used seem to be too broad, and constants of primitive types get it - as far as I can see needlessly, since such constants worked fine before this change. This adds load-time overhead and bloats the wrappers. The additional code and the pile of extra symbols probably mean run-time overhead too. @ptomulik It looks like this was mostly your patch. This is the gating conditional in current git master - any idea how we can tweak this to only fire for the cases that need it?
|
I would appreciate more discussion/resolution on this issue. @ptomulik ? Thanks in advance |
From discussion on #debian-devel, the issue yoh is seeing is that the constants themselves now seem to have the suffix |
OK, so that aspect is resolved - the problem was due to using That still leaves us with the pessimisation of the needless helpers for primitive types, which would be good to fix. @ptomulik Did you see my question 3 comments above? |
the only complication is that if previous code was using all the interface constructs, I would need to convert to "proper" Pythonish style, e.g.
and now getting some error on what I don't think I am setting anywhere... so more to be done later. And the question remains either lazy me could have just maintained the use of the same old |
To overcome swig/swig#563 incompatibility with swig 3.0 Ideally we should have redone this interface by borrowing Cython-based from sklearn... heh
Hi @yarikoptic, have you tried |
@ptomulik thanks for the idea... but so far I seem finding peace with RFing to just use the svmc import: yarikoptic/PyMVPA@b63b9d5 . Yet to give it more testing to see if nothing is left behind |
@ptomulik While But I don't understand the Could you at least explain what that condition is trying to check for? |
@ojwb, if you take a look at the patch https://github.com/swig/swig/pull/250/files, you'll see the original (pre-patch) logics for generating stuff into shadow file was like this: if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
if (!in_class) {
Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL);
} else {
if (!(Getattr(n, "feature:python:callback"))) {
Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL);
}
}
} I used the above code as a starting point for conditional generation of the if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER))) {
if (!in_class) {
Printv(f_shadow, "\n",NIL);
Printv(f_shadow, module, ".", iname, "_swigconstant(",module,")\n", NIL);
Printv(f_shadow, iname, " = ", module, ".", iname, "\n", NIL);
} else {
if (!(Getattr(n, "feature:python:callback"))) {
Printv(f_shadow_stubs, "\n",NIL);
Printv(f_shadow_stubs, module, ".", iname, "_swigconstant(", module, ")\n", NIL);
Printv(f_shadow_stubs, iname, " = ", module, ".", iname, "\n", NIL);
}
} A second step was to conditionally generate the actual implementation of if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
// Generate method which registers the new constant
// ...
} I must admit, I really have no idea why the original logics was as such, except the I think it would be better, if we could also disable the boilerplate for primitive types, but I have no idea how to distinguish them from non-primitives. |
And, my justification for |
Please see PR #631. |
Fixed in #631. |
Please pardon my ignorance in swig since I haven't actively used it in the past years. While preparing new release of PyMVPA I have ran into failed builds due to the fact that constants we had defined in svmc.i interface (https://github.com/PyMVPA/PyMVPA/blob/master/mvpa2/clfs/libsvmc/svmc.i#L142)
used to build Python bindings acquired _swigconstant suffixes all of a sudden. with 3.0.4 it is fine, with 3.0.5 we get already _swigregister (introduced in rel-3.0.3-5-gc21e242) which then later got renamed in rel-3.0.3-6-gcfaf2f9 into _swigconstant.
I guess it all was intentional and for common good, but I thought to double-check and may be seek some guru advice if there is possibly a cmdline (or other) option to revert to original behavior, possibly making it not too complicated to support multiple versions of swig across various platforms. Thank you in advance!
The text was updated successfully, but these errors were encountered: