美文网首页Julia语言
Julia与Python的主要不同点

Julia与Python的主要不同点

作者: Julia语言 | 来源:发表于2018-12-05 18:20 被阅读223次
  • Julia requires end to end a block. Unlike Python, Julia has no pass 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. a[2:3] in Julia is a[1:3] in Python.
  • Julia does not support negative indices. In particular, the last element of a list or array is indexed with endin Julia, not -1 as in Python.
  • Julia's for, if, while, etc. blocks are terminated by the end 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. +=, -=, ...) are not in-place whereas NumPy's are. This means A = [1, 1]; B = A; B += [3, 3] doesn't change values in A, it rather rebinds the name B to the result of the right-hand side B = B + 3, which is a new array. For in-place operation, use B .+= 3 (see also dot operators), explicit loops, or InplaceOps.jl.
  • 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 f(x=rand()) = x returns a new random number every time it is invoked without argument. On the other hand, the function g(x=[1,2]) = push!(x,3) returns [1,2,3] every time it is called as g().
  • In Julia % is the remainder operator, whereas in Python it is the modulus.
欢迎关注微信公众账号Julia语言.jpg

点击阅读原文可查看历史文章

相关文章

  • Julia与Python的主要不同点

    Julia requires end to end a block. Unlike Python, Julia h...

  • Julia语言之 Dict

    Julia 中的字典(Hash/Map)结构, 名为 Dict, 与 Python 中的名字一致.但 Julia ...

  • julia编程 单元测试的写法

    julia是一门十分适合用于科学计算的语言. 个人学习julia的主要目的就是为了科学计算,相比于python,性...

  • Julia中的分数

    微信公众号:Julia语言每周一三五更新Julia语言;每周二四六更新Python进阶; Julia中的分数 分数...

  • Julia中的复数

    微信公众号:Julia语言每周一三五更新Julia语言;每周二四六更新Python进阶; Julia中的复数 全局...

  • Julia中的字符

    微信公众号:Julia语言每周一三五更新Julia语言;每周二四六更新Python进阶; Julia中的字符 Ch...

  • Julia中的字符串概况

    微信公众号:Julia语言每周一三五更新Julia语言;每周二四六更新Python进阶; Julia中的字符串概况...

  • Julia 教程 从入门到进阶与笔记整理

    Julia 视频教程Julia教程1 简介及安装Julia教程2 REPL与变量Julia教程3 数学运算与矩...

  • Calling julia functions from pyt

    一、python调用julia的原理 二、使用的包:Pyjulia 三、环境搭建1、首先你确保你安装了julia2...

  • atom 安装及使用

    atom编辑器可以用于julia,python。 一、juno juno是一个免费的Julia语言开发环境,除了一...

网友评论

    本文标题:Julia与Python的主要不同点

    本文链接:https://www.haomeiwen.com/subject/yielqqtx.html