推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
mathzhaoliang
V2EX  ›  Python

请教个问题: Python 的 numpy 中 @ 运算符怎么实现的

  •  
  •   mathzhaoliang ·
    neozhaoliang · Nov 18, 2020 · 3100 views
    This topic created in 2006 days ago, the information mentioned may be changed or developed.

    numpy 里面矩阵乘法可以写成 A @ B,但是我看 Python 语法中标准运算符不包含 @ 呀?它是怎么实现的呢?

    是不是可以自己定义运算符,比如 str1 -- str2 表示将两个字符串 concat 起来?

    5 replies    2020-11-18 17:05:34 +08:00
    Death
        1
    Death  
       Nov 18, 2020 via Android   ❤️ 2
    cigarzh
        2
    cigarzh  
       Nov 18, 2020
    谁说 Python 运算符不包含 @的
    wwqgtxx
        3
    wwqgtxx  
       Nov 18, 2020 via iPhone
    可能你看的是 py2 时代的语法吧
    szuwl
        4
    szuwl  
       Nov 18, 2020
    运算符重载带来的功能呗,Python 的底层就是 C,这有什么好疑惑的
    lithbitren
        5
    lithbitren  
       Nov 18, 2020
    https://docs.python.org/zh-cn/3.9/reference/datamodel.html?highlight=matmul#object.__matmul__


    标准语法里有的,矩阵乘法,重载对象的__matmul__方法就行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2957 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 50ms · UTC 05:31 · PVG 13:31 · LAX 22:31 · JFK 01:31
    ♥ Do have faith in what you're doing.