View Full Version : Best scripting notation
Cyberia
5th July 2004, 19:53
Is there a real or perceived difference in writing scripts like this:
video=AVISource("Foo.avi")
video=video.ConvertToYV12()
video=video.Crop(6, 0, -6, -0)
video=video.TurnLeft()
video
versus writing them like this:
AVISource("Foo.avi").ConvertToYV12().Crop(6, 0, -6, -0).TurnLeft()
The first is easier to read, but I suspect it causes an extra memory copy at each step, where the second might not. Not sure if that would make a speed difference though.
Originally posted by Cyberia
The first is easier to read, but I suspect it causes an extra memory copy at each step, where the second might not. Not sure if that would make a speed difference though.
Well, the only extra memory copy would probably be copying a 4 byte pointer to the resulting clip from one variable to another, which - when compared with the CPU time a real filter needs - is exactly zilch. :)
(Unless there's some horrible misdesign somewhere in there where a full clip is copied around in memory each time, but I very much doubt that's the case... ;))
np: Vladislav Delay - Gold Chains Remix (Nonhuume)
Bidoche
6th July 2004, 00:01
The first version has some overhead due to variable lookup, but as Leak pointed out, it's totally unsignificant compared to render time.
And personally I think the second is easier to read.
Richard Berg
6th July 2004, 09:00
When building a new script I'll often use something like the first way so I can watch the different filters just by changing the last line.
video1=AVISource("Foo.avi")
video2=video.ConvertToYV12()
video3=video.Crop(6, 0, -6, -0)
video4=video.TurnLeft()
return videoX
There's no difference in performance.
lamer_de
6th July 2004, 16:53
I usually use this notation, that way I keep the readability relatively high and don't have to type the superflous "video=" every time ;)
AVISource("Foo.avi").\
ConvertToYV12().\
Crop(6, 0, -6, -0).\
TurnLeft()
CU,
lamer_de
stickboy
6th July 2004, 18:31
But if that's all, you can use the implicit "last" variable, and you don't need the .'s or \'s.
AVISource("Foo.avi")
ConvertToYV12()
Crop(6, 0, -6, -0)
TurnLeft()
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.