Replies: 1 comment 3 replies
-
There is a nuance here. In Python, function arguments are technically passed by value. Python objects are reference counted pointers, and copying the pointer increments the reference count. The underlying data is accessed by reference still. You will notice this if you mutate an integer, floating point, or string value function argument in Python -- the effects are not visible to the caller. In Mojo, the PythonObject type is modelled precisely like this -- a pass by value object that can contain a reference counter pointer. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey, first of all thanks for working on Mojo, I have to say I'm definitely excited about this language!
One of the intended features of Mojo that makes it very attractive is the goal of becoming a superset of Python. But are we talking about actually being a superset in the strict sense? Asking this because some of the design choices don't seem to be compatible with Python, specifically the default behavior of
def
:From https://docs.modular.com/mojo/programming-manual.html#comparing-def-and-fn-argument-passing
Isn't this incompatible with Python, in which arguments are typically passed by (mutable) reference?
Beta Was this translation helpful? Give feedback.
All reactions