This is doing more work than is need. Just `static_cast` the `double` to a `long` and use `PyInt_FromLong`. Something like this should work:

```
return PyInt_FromLong( static_cast<long>( PyFloat_AS_DOUBLE( newvalue ) ) )
```

This presents a bit of asymmetry with respect to the long handle: if a long it too large for an int, it will raise, but not for the doubles, so it may make sense to overflow checking for the double using `std::numeric_limits<long>::max()` and `std::numeric_limits<long>::min()` which will not incur a runtime cost to evaluate.

Also, I think `floats` are going to be more common than `longs`, so it makes sense to put the float check clause before the long check clause.