示例#1
0
        /// <summary>
        /// Multiply two object[] arrays - internal version used for objects backed by arrays
        /// </summary>
        internal static object[] Multiply(object[] data, int size, int count)
        {
            int newCount;

            try {
                newCount = checked (size * count);
            } catch (OverflowException) {
                throw PythonOps.MemoryError();
            }

            object[] ret = ArrayOps.CopyArray(data, newCount);
            if (count > 0)
            {
                // this should be extremely fast for large count as it uses the same algoithim as efficient integer powers
                // ??? need to test to see how large count and n need to be for this to be fastest approach
                int block = size;
                int pos   = size;
                while (pos < newCount)
                {
                    Array.Copy(ret, 0, ret, pos, Math.Min(block, newCount - pos));
                    pos   += block;
                    block *= 2;
                }
            }
            return(ret);
        }
示例#2
0
        internal static object?[] Add(object?[] data1, int size1, object?[] data2, int size2)
        {
            var ret = ArrayOps.CopyArray(data1, size1 + size2);

            Array.Copy(data2, 0, ret, size1, size2);
            return(ret);
        }
示例#3
0
        internal static object CallWorker(CodeContext /*!*/ context, PythonType dt, IDictionary <string, object> kwArgs, object[] args)
        {
            object[] allArgs  = ArrayOps.CopyArray(args, kwArgs.Count + args.Length);
            string[] argNames = new string[kwArgs.Count];

            int i = args.Length;

            foreach (KeyValuePair <string, object> kvp in kwArgs)
            {
                allArgs[i] = kvp.Value;
                argNames[i++ - args.Length] = kvp.Key;
            }

            return(CallWorker(context, dt, new KwCallInfo(allArgs, argNames)));
        }