Closed igorgodel closed 3 years ago
Excellent pickup on these compiler directives! I'll turn them on and investigate the results.
Great!
I'm turning them on one at a time and fixing now.
All warn.maybe_uninitialized
have been fixed.
All warn.unused
have been fixed except some generator expressions which I can't currently figure out how to modify to keep the compiler happy (so left this directive commented for now).
I fixed the two params in your point (3), however the compiler is picking up too many legitimate uses of self
in method signatures for that to be a useful directive to me. Please advise if you find any more redundant parameters yourself though.
I have fixed the items in your point (4). I'll leave the directive commented and investigate more closely at a later date.
Yes, the compiler is picking up too many legitimate uses ...
Yes, leaving the directive commented is the best solution (for now) ...
After the release of the new version I'll try to view all warns
There is another question warning C4244: .. : conversion from 'int64_t' to 'double', possible loss of data warning C4244: .. : conversion from 'Py_ssize_t' to 'int', possible loss of data ... Sometimes it contains serious bugs and sometimes - not needed conversions. For example: "build/optimized\nautilus_trader\execution\cache.c(15163): warning C4244: '=': conversion from 'int64_t' to 'double', possible loss of data" If we open \nautilus_trader-1.116.1\nautilus_trader\execution\cache.pyx method: ExecutionCache.check_integrity we can find that implicit conversion int64_t to double is not necessary:
# current version
cdef double timestamp_us = unix_timestamp_us()
...
cdef int64_t total_us = round(unix_timestamp_us() - timestamp_us)
# new version
cdef int64_t timestamp_us = unix_timestamp_us()
...
cdef int64_t total_us = unix_timestamp_us() - timestamp_us
If you're able to review these and tell me what needs to be changed that would be much appreciated :1st_place_medal:
@igorgodel Current progress update on this issue:
I did find and fix some type conversion warnings, I'll keep running the check periodically and fixing as I go as each one requires some careful thought.
All warn.maybe_uninitialized
warnings have been fixed.
I've had another look at warn.unused_result
however it seems to pick up variables which are actually used, sometimes even on the next line. This warning class then possibly isn't something we could fix/incorporate into the build system ongoing?
I fixed some remaining warn.unused
warnings, however there still remains the following 2:
Error compiling Cython file:
------------------------------------------------------------
...
"sort_priority": r.get("sortPriority"),
}
for r in market_definition["runners"]
],
}
if all(k in market_definition for k in ("eventType", "event")):
^
------------------------------------------------------------
nautilus_trader/adapters/betfair/providers.pyx:227:13: Unused entry 'genexpr'
Error compiling Cython file:
------------------------------------------------------------
...
self._log.info(f"Pre-processing data stream...")
if self._stream:
# Set data stream start index
self._stream_index = next(
idx for idx, data in enumerate(self._stream) if start_ns <= data.ts_recv_ns
^
------------------------------------------------------------
nautilus_trader/backtest/data_producer.pyx:349:16: Unused entry 'genexpr'
I've had a go, however its not immediately obvious to me how to 'fix' these two warnings, save for rewriting the functions themselves.
Using Cython compiler directives to detect bugs/improvements/corrections
Pay attention to the possibility to detect bugs/improvements/corrections using Cython compiler directives
Only some examples:
1) "warn.maybe_uninitialized" directive
NEED the detail analysis for each warning !!!
2) "warn.unused" directive
3) "warn.unused_arg" directive
4) "warn.unused_result" directive
Thanks