Mark `callMethod` as `discardable`
In order to avoid a slew of useless discard I'd suggest to mark the callMethod returning a PyObject as discardable.
I'd really try to avoid discardable as long as possible and would welcome other solutions, like passing ret typedesc to the function. I'd like to hear more complaints before adding discardable to the public interface about which I will regret after some time but will not be able to revert it without breaking.
Hmm, what I really meant was to have .() as discardable since that'd be a great improvement from an ergonomic point of view.
I wholeheartedly agree that putting discardable is a code smell.
what I really meant was...
Yes, that's precisely how I understood it. But is this a real problem though? Why would anyone want to call lots of python from nim?
I implement some python code using nimpy e.g. https://github.com/explosion/spaCy to support and test my nim code. Also other modules which are not available in nim I call from python.
I think it's not a real problem but would be nice to have.
Why would anyone want to call lots of python from nim
Because of Matplotlib and Seaborn :)
I hope the it is discardable, so the code in nim is just as same as in python.
proc plot_data(data: HistData) =
if not init_python(): return
plt.rcParams["font.sans-serif"]=["SimHei"]
plt.rcParams["axes.unicode_minus"] = false
plt.title(data.code)
let vtime = map(0..<data.len, i -> data.get_small_time(i))
set_xaxis(vtime, 8)
let fig = plt.figure(data.code)
fig.autofmt_xdate()
plt.plot(data.vclose)