File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -654,6 +654,18 @@ void CPyInt32_Overflow() {
654
654
655
655
int16_t CPyLong_AsInt16 (PyObject * o ) {
656
656
if (likely (PyLong_Check (o ))) {
657
+ #if CPY_3_12_FEATURES
658
+ PyLongObject * lobj = (PyLongObject * )o ;
659
+ size_t tag = CPY_LONG_TAG (lobj );
660
+ if (likely (tag == (1 << CPY_NON_SIZE_BITS ))) {
661
+ // Fast path
662
+ digit x = CPY_LONG_DIGIT (lobj , 0 );
663
+ if (x < 0x8000 )
664
+ return x ;
665
+ } else if (likely (tag == CPY_SIGN_ZERO )) {
666
+ return 0 ;
667
+ }
668
+ #else
657
669
PyLongObject * lobj = (PyLongObject * )o ;
658
670
Py_ssize_t size = lobj -> ob_base .ob_size ;
659
671
if (likely (size == 1 )) {
@@ -664,6 +676,7 @@ int16_t CPyLong_AsInt16(PyObject *o) {
664
676
} else if (likely (size == 0 )) {
665
677
return 0 ;
666
678
}
679
+ #endif
667
680
}
668
681
// Slow path
669
682
int overflow ;
You can’t perform that action at this time.
0 commit comments