[IronPython] Why would you use MakeList over MakeListNoCopy?

Dan Eloff dan.eloff at gmail.com
Sat Oct 11 22:29:09 CEST 2008


        /// <summary>
        /// Python runtime helper to create a populated instance of
Python List object.
        /// </summary>
        public static List MakeList(params object[] items) {
            return new List(items);
        }

        /// <summary>
        /// Python runtime helper to create a populated instance of
Python List object w/o
        /// copying the array contents.
        /// </summary>
        [NoSideEffects]
        public static List MakeListNoCopy(params object[] items) {
            return List.FromArrayNoCopy(items);
        }

If the second method "just works" then why would you ever want to use MakeList?

I seem to be creating a lot of 1 and 2 item lists here, so I'm looking
to make good use of one of these guys. (I really miss C# 3.0
collection initializers)

Work on porting _ast is going well, so far I've had no insurmountable
obstacles. I expect to be done it by Monday. The AST produced is close
(but not identical) to CPython, but that shouldn't matter. Each node
has the same properties with the exact same types so walking the tree
should work equally on both platforms.

Thanks,
-Dan



More information about the Ironpython-users mailing list