首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Julia与Python的主要不同点

Julia requires to end a block. Unlike Python, Julia has no keyword.

In Julia, indexing of arrays, strings, etc. is 1-based not 0-based.

Julia's slice indexing includes the last element, unlike in Python. in Julia is in Python.

Julia does not support negative indices. In particular, the last element of a list or array is indexed with in Julia, not as in Python.

Julia's , , , etc. blocks are terminated by the keyword. Indentation level is not significant as it is in Python.

Julia has no line continuation syntax: if, at the end of a line, the input so far is a complete expression, it is considered done; otherwise the input continues. One way to force an expression to continue is to wrap it in parentheses.

Julia arrays are column major (Fortran ordered) whereas NumPy arrays are row major (C-ordered) by default. To get optimal performance when looping over arrays, the order of the loops should be reversed in Julia relative to NumPy (see relevant section of Performance Tips).

Julia's updating operators (e.g. , , …) arenot in-placewhereas NumPy's are. This means doesn't change values in , it rather rebinds the name to the result of the right-hand side , which is a new array. For in-place operation, use (see also dot operators), explicit loops, or .

Julia evaluates default values of function arguments every time the method is invoked, unlike in Python where the default values are evaluated only once when the function is defined. For example, the function returns a new random number every time it is invoked without argument. On the other hand, the function returns every time it is called as .

In Julia is the remainder operator, whereas in Python it is the modulus.

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20181126G0DHHM00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券