@@ -316,13 +316,6 @@ public void clear() {
316316 _storage . Clear ( ref _storage ) ;
317317 }
318318
319- #if ! IPY3
320- [ Python3Warning ( "dict.has_key() not supported in 3.x; use the in operator" ) ]
321- public bool has_key ( object key ) {
322- return DictionaryOps . has_key ( this , key ) ;
323- }
324- #endif
325-
326319 public object pop ( object key ) {
327320 return DictionaryOps . pop ( this , key ) ;
328321 }
@@ -343,51 +336,12 @@ public object setdefault(object key, object defaultValue) {
343336 return DictionaryOps . setdefault ( this , key , defaultValue ) ;
344337 }
345338
346- #if IPY3
347339 public DictionaryItemView items ( ) => new DictionaryItemView ( this ) ;
348340
349341 public DictionaryKeyView keys ( ) => new DictionaryKeyView ( this ) ;
350342
351343 public DictionaryValueView values ( ) => new DictionaryValueView ( this ) ;
352344
353- #else
354- public virtual PythonList keys ( ) {
355- PythonList res = new PythonList ( ) ;
356- foreach ( KeyValuePair < object , object > kvp in _storage . GetItems ( ) ) {
357- res . append ( kvp . Key ) ;
358- }
359- return res ;
360- }
361-
362- public virtual PythonList values ( ) {
363- PythonList res = new PythonList ( ) ;
364- foreach ( KeyValuePair < object , object > kvp in _storage . GetItems ( ) ) {
365- res . append ( kvp . Value ) ;
366- }
367- return res ;
368- }
369-
370- public virtual PythonList items ( ) {
371- PythonList res = new PythonList ( ) ;
372- foreach ( KeyValuePair < object , object > kvp in _storage . GetItems ( ) ) {
373- res . append ( PythonTuple . MakeTuple ( kvp . Key , kvp . Value ) ) ;
374- }
375- return res ;
376- }
377-
378- public IEnumerator iteritems ( ) => new DictionaryItemEnumerator ( _storage ) ;
379-
380- public IEnumerator iterkeys ( ) => new DictionaryKeyEnumerator ( _storage ) ;
381-
382- public IEnumerator itervalues ( ) => new DictionaryValueEnumerator ( _storage ) ;
383-
384- public IEnumerable viewitems ( ) => new DictionaryItemView ( this ) ;
385-
386- public IEnumerable viewkeys ( ) => new DictionaryKeyView ( this ) ;
387-
388- public IEnumerable viewvalues ( ) => new DictionaryValueView ( this ) ;
389- #endif
390-
391345 [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Performance" , "CA1822:MarkMembersAsStatic" ) ]
392346 public void update ( ) {
393347 }
@@ -458,12 +412,7 @@ public static object fromkeys(CodeContext context, PythonType cls, object seq) {
458412
459413 [ ClassMethod ]
460414 public static object fromkeys ( CodeContext context , PythonType cls , object seq , object value ) {
461- #if IPY3
462- Range xr = seq as Range ;
463- #else
464- XRange xr = seq as XRange ;
465- #endif
466- if ( xr != null ) {
415+ if ( seq is Range xr ) {
467416 int n = xr . __len__ ( ) ;
468417 object ret = context . LanguageContext . CallSplat ( cls ) ;
469418 if ( ret . GetType ( ) == typeof ( PythonDictionary ) ) {
@@ -514,45 +463,6 @@ public object __ne__(CodeContext/*!*/ context, object other) {
514463 ) ;
515464 }
516465
517- #if ! IPY3
518- [ return : MaybeNotImplemented ]
519- public object __cmp__ ( CodeContext context , object other ) {
520- IDictionary < object , object > oth = other as IDictionary < object , object > ;
521- // CompareTo is allowed to throw (string, int, etc... all do it if they don't get a matching type)
522- if ( oth == null ) {
523- object len , iteritems ;
524- if ( ! PythonOps . TryGetBoundAttr ( context , other , "__len__" , out len ) ||
525- ! PythonOps . TryGetBoundAttr ( context , other , "iteritems" , out iteritems ) ) {
526- return NotImplementedType . Value ;
527- }
528-
529- // user-defined dictionary...
530- int lcnt = Count ;
531- int rcnt = context . LanguageContext . ConvertToInt32 ( PythonOps . CallWithContext ( context , len ) ) ;
532-
533- if ( lcnt != rcnt ) return lcnt > rcnt ? 1 : - 1 ;
534-
535- return DictionaryOps . CompareToWorker ( context , this , new PythonList ( PythonOps . CallWithContext ( context , iteritems ) ) ) ;
536- }
537-
538- CompareUtil . Push ( this , oth ) ;
539- try {
540- return DictionaryOps . CompareTo ( context , this , oth ) ;
541- } finally {
542- CompareUtil . Pop ( this , oth ) ;
543- }
544- }
545-
546- public int __cmp__ ( CodeContext /*!*/ context , [ NotNull ] PythonDictionary /*!*/ other ) {
547- CompareUtil . Push ( this , other ) ;
548- try {
549- return DictionaryOps . CompareTo ( context , this , other ) ;
550- } finally {
551- CompareUtil . Pop ( this , other ) ;
552- }
553- }
554- #endif
555-
556466 // these are present in CPython but always return NotImplemented.
557467 [ return : MaybeNotImplemented ]
558468 [ Python3Warning ( "dict inequality comparisons not supported in 3.x" ) ]
@@ -889,11 +799,7 @@ public override List<KeyValuePair<object, object>> GetItems() {
889799 /// innerEnum.MoveNext() will throw InvalidOperation even if the values get changed,
890800 /// which is supported in python
891801 /// </summary>
892- #if IPY3
893802 [ PythonType ( "dict_keyiterator" ) ]
894- #else
895- [ PythonType ( "dictionary-keyiterator" ) ]
896- #endif
897803 public sealed class DictionaryKeyEnumerator : IEnumerator < object > {
898804 private readonly int _size ;
899805 private readonly DictionaryStorage _dict ;
@@ -937,13 +843,11 @@ void IDisposable.Dispose() { }
937843
938844 #region Pickling
939845
940- #if IPY3
941846 public object __reduce__ ( CodeContext context ) {
942847 object iter ;
943848 context . TryLookupBuiltin ( "iter" , out iter ) ;
944849 return PythonTuple . MakeTuple ( iter , PythonTuple . MakeTuple ( PythonList . FromArrayNoCopy ( _dict . GetKeys ( ) . Skip ( _pos + 1 ) . ToArray ( ) ) ) ) ;
945850 }
946- #endif
947851
948852 #endregion
949853 }
@@ -954,11 +858,7 @@ public object __reduce__(CodeContext context) {
954858 /// innerEnum.MoveNext() will throw InvalidOperation even if the values get changed,
955859 /// which is supported in python
956860 /// </summary>
957- #if IPY3
958861 [ PythonType ( "dict_valueiterator" ) ]
959- #else
960- [ PythonType ( "dictionary-valueiterator" ) ]
961- #endif
962862 public sealed class DictionaryValueEnumerator : IEnumerator < object > {
963863 private readonly int _size ;
964864 private DictionaryStorage _dict ;
@@ -1005,13 +905,11 @@ void IDisposable.Dispose() { }
1005905
1006906 #region Pickling
1007907
1008- #if IPY3
1009908 public object __reduce__ ( CodeContext context ) {
1010909 object iter ;
1011910 context . TryLookupBuiltin ( "iter" , out iter ) ;
1012911 return PythonTuple . MakeTuple ( iter , PythonTuple . MakeTuple ( PythonList . FromArrayNoCopy ( _dict . GetItems ( ) . Skip ( _pos + 1 ) . Select ( x => x . Value ) . ToArray ( ) ) ) ) ;
1013912 }
1014- #endif
1015913
1016914 #endregion
1017915 }
@@ -1022,11 +920,7 @@ public object __reduce__(CodeContext context) {
1022920 /// innerEnum.MoveNext() will throw InvalidOperation even if the values get changed,
1023921 /// which is supported in python
1024922 /// </summary>
1025- #if IPY3
1026923 [ PythonType ( "dict_itemiterator" ) ]
1027- #else
1028- [ PythonType ( "dictionary-itemiterator" ) ]
1029- #endif
1030924 public sealed class DictionaryItemEnumerator : IEnumerator < object > {
1031925 private readonly int _size ;
1032926 private readonly DictionaryStorage _dict ;
@@ -1075,13 +969,11 @@ void IDisposable.Dispose() { }
1075969
1076970 #region Pickling
1077971
1078- #if IPY3
1079972 public object __reduce__ ( CodeContext context ) {
1080973 object iter ;
1081974 context . TryLookupBuiltin ( "iter" , out iter ) ;
1082975 return PythonTuple . MakeTuple ( iter , PythonTuple . MakeTuple ( PythonList . FromArrayNoCopy ( _dict . GetItems ( ) . Skip ( _pos + 1 ) . Select ( x => x . Value ) . ToArray ( ) ) ) ) ;
1083976 }
1084- #endif
1085977
1086978 #endregion
1087979 }
@@ -1541,14 +1433,12 @@ public string __repr__(CodeContext context) {
15411433
15421434 #endregion
15431435
1544- #if IPY3
15451436 public bool isdisjoint ( IEnumerable other ) {
15461437 return SetStorage . Intersection (
15471438 SetStorage . GetItemsWorker ( GetEnumerator ( ) ) ,
15481439 SetStorage . GetItems ( other )
15491440 ) . Count == 0 ;
15501441 }
1551- #endif
15521442
15531443 public override int GetHashCode ( ) {
15541444 return base . GetHashCode ( ) ;
@@ -1903,14 +1793,12 @@ public string __repr__(CodeContext context) {
19031793
19041794 #endregion
19051795
1906- #if IPY3
19071796 public bool isdisjoint ( IEnumerable other ) {
19081797 return SetStorage . Intersection (
19091798 SetStorage . GetItemsWorker ( GetEnumerator ( ) ) ,
19101799 SetStorage . GetItems ( other )
19111800 ) . Count == 0 ;
19121801 }
1913- #endif
19141802
19151803 public override int GetHashCode ( ) {
19161804 return base . GetHashCode ( ) ;
0 commit comments