Using @code_warntype in Julia

When trying to write type-resistant code while studying with @code_warntype, should I only worry about what I don't have Anyeither Unionin the variable section or should I also check the body section?

+4
source share
2 answers

Depending on your version of julia, @code_warntypecertain harmless expressions may sometimes be specified. With a little practice, you can easily recognize these expressions (for example, they are often associated with finding modules and names).

The easy way, as Reza says, is to look at the variable section and the return-type function; if you don't see any uncertain values ​​(either Anyor Unions), you probably have nothing to worry about. If you want to dig deeper, start trying to understand the body expressions that he notes. For training, it is useful to compare the results with the results obtained using track-allocation, since the true type instability is associated with the memory allocation.

However, I think that problems with @code_warntypewere fixed for the current wizard, so in any case, the next version of julia should simplify the interpretation.

+7
source

- , code_warntype , , ( ). , .

:

+3

Source: https://habr.com/ru/post/1617552/


All Articles