RE: [Maya-Python] C++ speed/efficiency in Maya

2021-04-06 Thread bobrobertuma
Maya 2022 is Python 3 support.  As I understand it it’s similar but probably 
has little effect on this discussion.  However as a 2020 perpetual user I won’t 
be using Py3 in Maya..

 

Thanks for the interesting insights on mel - py.

 

From: python_inside_maya@googlegroups.com 
[mailto:python_inside_maya@googlegroups.com] On Behalf Of Justin Israel
Sent: Tuesday, April 06, 2021 3:31 AM
To: python_inside_maya@googlegroups.com
Subject: Re: [Maya-Python] C++ speed/efficiency in Maya

 

 

On Tue, 6 Apr 2021, 5:53 pm Marcus Ottosson, mailto:konstrukt...@gmail.com> > wrote:

In many cases, MEL should be faster than pure python

I thought so too!

But to my great surprise, for a lot of common operations - like createNode, 
getAttr and setAttr - MEL was consisteny significantly slower than cmds.

* https://github.com/mottosso/cmdx#timings

These were done in Maya 2015, so it’s possible but unlikely things have changed 
since then. There’s a script in there to reproduce the results (independent of 
cmdx).

 

Ya totally. I should have emphasized the point even more that "it depends". On 
measuring individual function calls, you may find that an OpenMaya api call 
through python is faster. Mel is likely faster in comparing basic language 
constructs like loops. But the calls into the Maya api depend on how they are 
backed by C++

All one can really do is test actual cases. Specific function calls may have 
their own micro benchmark timings. I came across this earlier today:

https://www.diva-portal.org/smash/get/diva2:1334763/FULLTEXT02

 

 

 

On Tue, 6 Apr 2021 at 02:52, Justin Israel mailto:justinisr...@gmail.com> > wrote:

 

 

On Tue, Apr 6, 2021 at 11:52 AM bobrobertuma mailto:bobrobert...@gmail.com> > wrote:

Always wondered if mel or derivative of C# basically is faster than py?  Or as 
they are both script languages perhaps not much different.

 

 

In many cases, MEL should be faster than pure python, because it is a much more 
limited and special purpose scripting language implemented for Maya. Static 
typing and less language constructs mean it should have less overhead to 
execute after it is parsed. But when comparing these things you would have to 
account for the fact that a lot of function calls in python are backed by C, so 
it depends what you are doing. 

Also, while MEL might be faster in some cases, it is also not as convenient as 
Python when it comes to having more libraries and utilities at your disposal, 
and better integration with your development environment. MEL is really just 
glue code for calling all of the pre-built functions. 

 

 

From: python_inside_maya@googlegroups.com 
<mailto:python_inside_maya@googlegroups.com>  
[mailto:python_inside_maya@googlegroups.com 
<mailto:python_inside_maya@googlegroups.com> ] On Behalf Of Justin Israel
Sent: Monday, April 05, 2021 4:01 PM
To: python_inside_maya@googlegroups.com 
<mailto:python_inside_maya@googlegroups.com> 
Subject: Re: [Maya-Python] C++ speed/efficience in Maya

 

 

 

On Tue, Apr 6, 2021 at 8:32 AM João Victor mailto:joaovictor...@gmail.com> > wrote:

Hey guys,

Could somebody help me in some doubt?

How faster C++ could be in Maya, compared to python API in general?

Is this something that worth to work with for what kind of programs (generally)?

 

Python is considered a relatively "slow" language, compared to C++. Because 
python is dynamically typed and interpreted, there is a lot more overhead 
involved with every variable access or function call, where python has to look 
up attributes and check types. A language like C++ is statically typed and 
compiled, so most of that overhead is gone since it has been determined at 
compile time. 

 

In terms of real world speed differences, and even more specifically to Maya, 
that will come down to what operations you are really doing. If you were to 
create a loop that runs over all points on a mesh, that could definitely be 
slower in python. C++ helps when there are critical sections of your code where 
performance must be very high, and profiling your code can tell you where the 
slow spots exist.

 

There is also a difference between using the Maya Commands module, vs using the 
Maya API that wraps the C++ sdk. More of the heavy lifting is moved into the 
C++ side when using the Maya API, whereas using the Maya commands has more 
python overhead.  

 

You could write a deformed in Python, but you might find it performs too slowly 
and then needs to be rewritten in C++. However, Python does help to speed up 
prototyping time and figure out where performance problems actually exist. On 
the other hand, you could write UI code or file translators, or renamers, or 
validators in Python and never see a need for C++ in those tools.

 

 

 

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group

Re: [Maya-Python] C++ speed/efficiency in Maya

2021-04-06 Thread Justin Israel
On Tue, 6 Apr 2021, 5:53 pm Marcus Ottosson,  wrote:

> In many cases, MEL should be faster than pure python
>
> I thought so too!
>
> But to my great surprise, for a lot of common operations - like createNode,
> getAttr and setAttr - MEL was consisteny *significantly slower* than cmds.
>
>- https://github.com/mottosso/cmdx#timings
>
> These were done in Maya 2015, so it’s possible but unlikely things have
> changed since then. There’s a script in there to reproduce the results
> (independent of cmdx).
>

Ya totally. I should have emphasized the point even more that "it depends".
On measuring individual function calls, you may find that an OpenMaya api
call through python is faster. Mel is likely faster in comparing basic
language constructs like loops. But the calls into the Maya api depend on
how they are backed by C++
All one can really do is test actual cases. Specific function calls may
have their own micro benchmark timings. I came across this earlier today:
https://www.diva-portal.org/smash/get/diva2:1334763/FULLTEXT02



> On Tue, 6 Apr 2021 at 02:52, Justin Israel  wrote:
>
>>
>>
>> On Tue, Apr 6, 2021 at 11:52 AM bobrobertuma 
>> wrote:
>>
>>> Always wondered if mel or derivative of C# basically is faster than py?
>>> Or as they are both script languages perhaps not much different.
>>>
>>
>>
>> In many cases, MEL should be faster than pure python, because it is a
>> much more limited and special purpose scripting language implemented for
>> Maya. Static typing and less language constructs mean it should have less
>> overhead to execute after it is parsed. But when comparing these things you
>> would have to account for the fact that a lot of function calls in python
>> are backed by C, so it depends what you are doing.
>> Also, while MEL might be faster in some cases, it is also not as
>> convenient as Python when it comes to having more libraries and utilities
>> at your disposal, and better integration with your development environment.
>> MEL is really just glue code for calling all of the pre-built functions.
>>
>>
>>>
>>> *From:* python_inside_maya@googlegroups.com [mailto:
>>> python_inside_maya@googlegroups.com] *On Behalf Of *Justin Israel
>>> *Sent:* Monday, April 05, 2021 4:01 PM
>>> *To:* python_inside_maya@googlegroups.com
>>> *Subject:* Re: [Maya-Python] C++ speed/efficience in Maya
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Tue, Apr 6, 2021 at 8:32 AM João Victor 
>>> wrote:
>>>
>>> Hey guys,
>>>
>>> Could somebody help me in some doubt?
>>>
>>> How faster C++ could be in Maya, compared to python API in general?
>>>
>>> Is this something that worth to work with for what kind of programs
>>> (generally)?
>>>
>>>
>>>
>>> Python is considered a relatively "slow" language, compared to C++.
>>> Because python is dynamically typed and interpreted, there is a lot more
>>> overhead involved with every variable access or function call, where python
>>> has to look up attributes and check types. A language like C++ is
>>> statically typed and compiled, so most of that overhead is gone since it
>>> has been determined at compile time.
>>>
>>>
>>>
>>> In terms of real world speed differences, and even more specifically to
>>> Maya, that will come down to what operations you are really doing. If you
>>> were to create a loop that runs over all points on a mesh, that could
>>> definitely be slower in python. C++ helps when there are critical sections
>>> of your code where performance must be very high, and profiling your code
>>> can tell you where the slow spots exist.
>>>
>>>
>>>
>>> There is also a difference between using the Maya Commands module, vs
>>> using the Maya API that wraps the C++ sdk. More of the heavy lifting is
>>> moved into the C++ side when using the Maya API, whereas using the Maya
>>> commands has more python overhead.
>>>
>>>
>>>
>>> You could write a deformed in Python, but you might find it performs too
>>> slowly and then needs to be rewritten in C++. However, Python does help to
>>> speed up prototyping time and figure out where performance problems
>>> actually exist. On the other hand, you could write UI code or file
>>> translators, or renamers, or validators in Python and never see a need for
>>> C++ in those tools.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Thanks in advance!
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to python_inside_maya+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/python_inside_maya/7315681e-e595-406a-ac82-2b7c05fab3dfn%40googlegroups.com
>>> 
>>> .
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for 

Re: [Maya-Python] C++ speed/efficiency in Maya

2021-04-05 Thread Marcus Ottosson
In many cases, MEL should be faster than pure python

I thought so too!

But to my great surprise, for a lot of common operations - like createNode,
getAttr and setAttr - MEL was consisteny *significantly slower* than cmds.

   - https://github.com/mottosso/cmdx#timings

These were done in Maya 2015, so it’s possible but unlikely things have
changed since then. There’s a script in there to reproduce the results
(independent of cmdx).

On Tue, 6 Apr 2021 at 02:52, Justin Israel  wrote:

>
>
> On Tue, Apr 6, 2021 at 11:52 AM bobrobertuma 
> wrote:
>
>> Always wondered if mel or derivative of C# basically is faster than py?
>> Or as they are both script languages perhaps not much different.
>>
>
>
> In many cases, MEL should be faster than pure python, because it is a much
> more limited and special purpose scripting language implemented for Maya.
> Static typing and less language constructs mean it should have less
> overhead to execute after it is parsed. But when comparing these things you
> would have to account for the fact that a lot of function calls in python
> are backed by C, so it depends what you are doing.
> Also, while MEL might be faster in some cases, it is also not as
> convenient as Python when it comes to having more libraries and utilities
> at your disposal, and better integration with your development environment.
> MEL is really just glue code for calling all of the pre-built functions.
>
>
>>
>> *From:* python_inside_maya@googlegroups.com [mailto:
>> python_inside_maya@googlegroups.com] *On Behalf Of *Justin Israel
>> *Sent:* Monday, April 05, 2021 4:01 PM
>> *To:* python_inside_maya@googlegroups.com
>> *Subject:* Re: [Maya-Python] C++ speed/efficience in Maya
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Apr 6, 2021 at 8:32 AM João Victor 
>> wrote:
>>
>> Hey guys,
>>
>> Could somebody help me in some doubt?
>>
>> How faster C++ could be in Maya, compared to python API in general?
>>
>> Is this something that worth to work with for what kind of programs
>> (generally)?
>>
>>
>>
>> Python is considered a relatively "slow" language, compared to C++.
>> Because python is dynamically typed and interpreted, there is a lot more
>> overhead involved with every variable access or function call, where python
>> has to look up attributes and check types. A language like C++ is
>> statically typed and compiled, so most of that overhead is gone since it
>> has been determined at compile time.
>>
>>
>>
>> In terms of real world speed differences, and even more specifically to
>> Maya, that will come down to what operations you are really doing. If you
>> were to create a loop that runs over all points on a mesh, that could
>> definitely be slower in python. C++ helps when there are critical sections
>> of your code where performance must be very high, and profiling your code
>> can tell you where the slow spots exist.
>>
>>
>>
>> There is also a difference between using the Maya Commands module, vs
>> using the Maya API that wraps the C++ sdk. More of the heavy lifting is
>> moved into the C++ side when using the Maya API, whereas using the Maya
>> commands has more python overhead.
>>
>>
>>
>> You could write a deformed in Python, but you might find it performs too
>> slowly and then needs to be rewritten in C++. However, Python does help to
>> speed up prototyping time and figure out where performance problems
>> actually exist. On the other hand, you could write UI code or file
>> translators, or renamers, or validators in Python and never see a need for
>> C++ in those tools.
>>
>>
>>
>>
>>
>>
>>
>> Thanks in advance!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/7315681e-e595-406a-ac82-2b7c05fab3dfn%40googlegroups.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA26Nns6Nt9NYDvgF0YrhH_8B%3D77rgVQmkSyA32gcz9PgA%40mail.gmail.com
>> 
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Python Programming for Autodesk Maya" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to 

Re: [Maya-Python] C++ speed/efficiency in Maya

2021-04-05 Thread Justin Israel
On Tue, Apr 6, 2021 at 11:52 AM bobrobertuma  wrote:

> Always wondered if mel or derivative of C# basically is faster than py?
> Or as they are both script languages perhaps not much different.
>


In many cases, MEL should be faster than pure python, because it is a much
more limited and special purpose scripting language implemented for Maya.
Static typing and less language constructs mean it should have less
overhead to execute after it is parsed. But when comparing these things you
would have to account for the fact that a lot of function calls in python
are backed by C, so it depends what you are doing.
Also, while MEL might be faster in some cases, it is also not as convenient
as Python when it comes to having more libraries and utilities at your
disposal, and better integration with your development environment. MEL is
really just glue code for calling all of the pre-built functions.


>
> *From:* python_inside_maya@googlegroups.com [mailto:
> python_inside_maya@googlegroups.com] *On Behalf Of *Justin Israel
> *Sent:* Monday, April 05, 2021 4:01 PM
> *To:* python_inside_maya@googlegroups.com
> *Subject:* Re: [Maya-Python] C++ speed/efficience in Maya
>
>
>
>
>
>
>
> On Tue, Apr 6, 2021 at 8:32 AM João Victor 
> wrote:
>
> Hey guys,
>
> Could somebody help me in some doubt?
>
> How faster C++ could be in Maya, compared to python API in general?
>
> Is this something that worth to work with for what kind of programs
> (generally)?
>
>
>
> Python is considered a relatively "slow" language, compared to C++.
> Because python is dynamically typed and interpreted, there is a lot more
> overhead involved with every variable access or function call, where python
> has to look up attributes and check types. A language like C++ is
> statically typed and compiled, so most of that overhead is gone since it
> has been determined at compile time.
>
>
>
> In terms of real world speed differences, and even more specifically to
> Maya, that will come down to what operations you are really doing. If you
> were to create a loop that runs over all points on a mesh, that could
> definitely be slower in python. C++ helps when there are critical sections
> of your code where performance must be very high, and profiling your code
> can tell you where the slow spots exist.
>
>
>
> There is also a difference between using the Maya Commands module, vs
> using the Maya API that wraps the C++ sdk. More of the heavy lifting is
> moved into the C++ side when using the Maya API, whereas using the Maya
> commands has more python overhead.
>
>
>
> You could write a deformed in Python, but you might find it performs too
> slowly and then needs to be rewritten in C++. However, Python does help to
> speed up prototyping time and figure out where performance problems
> actually exist. On the other hand, you could write UI code or file
> translators, or renamers, or validators in Python and never see a need for
> C++ in those tools.
>
>
>
>
>
>
>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/7315681e-e595-406a-ac82-2b7c05fab3dfn%40googlegroups.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA26Nns6Nt9NYDvgF0YrhH_8B%3D77rgVQmkSyA32gcz9PgA%40mail.gmail.com
> 
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/003e01d72a76%24bc9e2fb0%2435da8f10%24%40gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this 

RE: [Maya-Python] C++ speed/efficiency in Maya

2021-04-05 Thread bobrobertuma
Always wondered if mel or derivative of C# basically is faster than py?  Or as 
they are both script languages perhaps not much different.

 

From: python_inside_maya@googlegroups.com 
[mailto:python_inside_maya@googlegroups.com] On Behalf Of Justin Israel
Sent: Monday, April 05, 2021 4:01 PM
To: python_inside_maya@googlegroups.com
Subject: Re: [Maya-Python] C++ speed/efficience in Maya

 

 

 

On Tue, Apr 6, 2021 at 8:32 AM João Victor mailto:joaovictor...@gmail.com> > wrote:

Hey guys,

Could somebody help me in some doubt?

How faster C++ could be in Maya, compared to python API in general?

Is this something that worth to work with for what kind of programs (generally)?

 

Python is considered a relatively "slow" language, compared to C++. Because 
python is dynamically typed and interpreted, there is a lot more overhead 
involved with every variable access or function call, where python has to look 
up attributes and check types. A language like C++ is statically typed and 
compiled, so most of that overhead is gone since it has been determined at 
compile time. 

 

In terms of real world speed differences, and even more specifically to Maya, 
that will come down to what operations you are really doing. If you were to 
create a loop that runs over all points on a mesh, that could definitely be 
slower in python. C++ helps when there are critical sections of your code where 
performance must be very high, and profiling your code can tell you where the 
slow spots exist.

 

There is also a difference between using the Maya Commands module, vs using the 
Maya API that wraps the C++ sdk. More of the heavy lifting is moved into the 
C++ side when using the Maya API, whereas using the Maya commands has more 
python overhead.  

 

You could write a deformed in Python, but you might find it performs too slowly 
and then needs to be rewritten in C++. However, Python does help to speed up 
prototyping time and figure out where performance problems actually exist. On 
the other hand, you could write UI code or file translators, or renamers, or 
validators in Python and never see a need for C++ in those tools.

 

 

 

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com 
 .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/7315681e-e595-406a-ac82-2b7c05fab3dfn%40googlegroups.com
 

 .

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com 
 .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA26Nns6Nt9NYDvgF0YrhH_8B%3D77rgVQmkSyA32gcz9PgA%40mail.gmail.com
 

 .

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/003e01d72a76%24bc9e2fb0%2435da8f10%24%40gmail.com.