public static object FromKeys(PythonType cls, object seq, object value) { XRange xr = seq as XRange; if (xr != null) { int n = xr.GetLength(); object ret = MakeDict(cls); if (ret.GetType() == typeof(Dict)) { Dict dr = ret as Dict; for (int i = 0; i < n; i++) { dr[xr[i]] = value; } } else { // slow path, user defined dict for (int i = 0; i < n; i++) { Ops.SetIndex(ret, xr[i], value); } } return(ret); } return(fromkeysAny(cls, seq, value)); }
public static object fromkeys(CodeContext context, PythonType cls, object seq, object value) { XRange xr = seq as XRange; if (xr != null) { int n = xr.__len__(); object ret = PythonContext.GetContext(context).CallSplat(cls); if (ret.GetType() == typeof(PythonDictionary)) { PythonDictionary dr = ret as PythonDictionary; for (int i = 0; i < n; i++) { dr[xr[i]] = value; } } else { // slow path, user defined dict PythonContext pc = PythonContext.GetContext(context); for (int i = 0; i < n; i++) { pc.SetIndex(ret, xr[i], value); } } return(ret); } return(fromkeysAny(context, cls, seq, value)); }
public XRangeIterator(XRange l) { this.l = l; this.value = l.start - l.step; // this could cause overflow, fine this.position = 0; }
public XRangeIterator(XRange xrange) { _xrange = xrange; _value = xrange.Start - xrange.Step; // this could cause overflow, fine }