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

scipy.weave.inline ignores changed support code (Trac #1143) #1670

Closed
Tracked by #7
scipy-gitbot opened this issue Apr 25, 2013 · 3 comments
Closed
Tracked by #7

scipy.weave.inline ignores changed support code (Trac #1143) #1670

scipy-gitbot opened this issue Apr 25, 2013 · 3 comments
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac

Comments

@scipy-gitbot
Copy link

Original ticket http://projects.scipy.org/scipy/ticket/1143 on 2010-03-29 by trac user jzikovsky, assigned to unknown.

I am running python 2.6.4. OS: Ubuntu. I installed the Enthought Python Distribution just a month or 2 ago, so it should be pretty recent. Here is a snippet that reliably works incorrectly on my machine:

from scipy import weave

support = """
int support_function(int value)
{
    printf("This is function A! You gave %d\\n", value);
    return value*2;
}
"""
code = """
support_function(10);
"""
ret = weave.inline(code, [], compiler='gcc', support_code=support)

support = """
int support_function(int value)
{
    printf("This is function B which is completely different! You gave %d\\n", value);
    return value*1000;
}
"""
#code is unchanged, support has changed though.
#But the result is the same from this execution as the one before!
ret = weave.inline(code, [], compiler='gcc', support_code=support)

output is the following:

This is function A! You gave 10
This is function A! You gave 10

but it should be:

This is function A! You gave 10
This is function B which is completely different! You gave 10
@scipy-gitbot
Copy link
Author

@stefanv wrote on 2010-03-29

The function cache uses "code" as its key. Since you use exactly the same code in both cases, it will not distinguish between them. You can trigger a recompile by any minor change to the code, for example:

code1 = """
support_function(10);
"""

code2 = """
support_function(10); //
"""

@scipy-gitbot
Copy link
Author

trac user jzikovsky wrote on 2010-03-30

Yes, I've been working around this issue this way. My support code would change dynamically, so in one instance, I used:

code += "/* " + support + " */"

which would put the support code inside the key, though commented out. This way the recompilation would occur whenever it was really needed. This would fail if the support code had any /* */ comments though, so I just avoided those.

This behavior is a bit surprising, and does not seem to be documented; IMHO the cache key should use the code and the support code together (code+support).

@person142
Copy link
Member

Closing since weave is no longer a part of SciPy. This issue is now tracked at scipy/weave#7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected Migrated from Trac
Projects
None yet
Development

No branches or pull requests

2 participants