C is it always faster than nump?

Edmondo Giovannozzi edmondo.giovannozzi at gmail.com
Mon Feb 28 07:20:10 EST 2022


Il giorno sabato 26 febbraio 2022 alle 19:41:37 UTC+1 Dennis Lee Bieber ha scritto:
> On Fri, 25 Feb 2022 21:44:14 -0800, Dan Stromberg <drsa... at gmail.com> 
> declaimed the following:
> >Fortran, (still last I heard) did not support pointers, which gives Fortran 
> >compilers the chance to exploit a very nice class of optimizations you 
> >can't use nearly as well in languages with pointers. 
> >
> Haven't looked much at Fortran-90/95 then... 
> 
> Variable declaration gained a POINTER qualifier, and there is an 
> ALLOCATE intrinsic to obtain memory. 
> 
> And with difficulty one could get the result in DEC/VMS FORTRAN-77 
> since DEC implemented (across all their language compilers) intrinsics 
> controlling how arguments are passed -- overriding the language native 
> passing: 
> CALL XYZ(%val(M)) 
> would actually pass the value of M, not Fortran default address-of, with 
> the result that XYZ would use that value /as/ the address of the actual 
> argument. (Others were %ref() and %descr() -- descriptor being a small 
> structure with the address reference along with, say, upper/lower bounds; 
> often used for strings).
> -- 
> Wulfraed Dennis Lee Bieber AF6VN 
> wlf... at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

The latest Fortran revision is the 2018.
A variable can also have the VALUE attribute even though nowhere in the standard is written that it means passing the data by value. It just means that if a variable is changed in a procedure the changes don't propagate back to the caller.
With the iso_c_binding one can directly call a C function or let a Fortran procedure appear as a C function. There is the C_LOC that gives the C address of a variable if needed. Of course from 2003 it is fully object oriented.
The claim that it was faster then C is mostly related to the aliasing rule that is forbidden in Fortran. The C introduced the "restrict" qualifier for the same reason.
In Fortran you also have array operation like you have in numpy. 


More information about the Python-list mailing list