@@ -2705,14 +2705,16 @@ protected boolean checkBase(int base) {
2705
2705
@ Builtin (name = "PySequence_Tuple" , minNumOfPositionalArgs = 1 )
2706
2706
@ GenerateNodeFactory
2707
2707
public abstract static class PySequenceTupleNode extends PythonUnaryBuiltinNode {
2708
- @ Specialization
2709
- public PTuple values (PTuple obj ) {
2708
+ @ Specialization (guards = "isTuple(obj, getClassNode)" )
2709
+ public PTuple values (PTuple obj ,
2710
+ @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ) {
2710
2711
return obj ;
2711
2712
}
2712
2713
2713
- @ Specialization
2714
- public Object values (VirtualFrame frame , Object obj ,
2714
+ @ Specialization ( guards = "!isTuple(obj, getClassNode)" )
2715
+ public Object values (VirtualFrame frame , Object obj ,
2715
2716
@ Cached TupleNode tupleNode ,
2717
+ @ SuppressWarnings ("unused" ) @ Cached GetClassNode getClassNode ,
2716
2718
@ Cached TransformExceptionToNativeNode transformExceptionToNativeNode ,
2717
2719
@ Cached GetNativeNullNode getNativeNullNode ) {
2718
2720
try {
@@ -2722,6 +2724,10 @@ public Object values(VirtualFrame frame, Object obj,
2722
2724
return getNativeNullNode .execute ();
2723
2725
}
2724
2726
}
2727
+
2728
+ protected boolean isTuple (Object obj , GetClassNode getClassNode ) {
2729
+ return getClassNode .execute (obj ) == PythonBuiltinClassType .PTuple ;
2730
+ }
2725
2731
}
2726
2732
2727
2733
@ Builtin (name = "PySequence_List" , minNumOfPositionalArgs = 1 )
0 commit comments