Git Product home page Git Product logo

Comments (5)

kayhayen avatar kayhayen commented on September 26, 2024

I think "negation" of longs needs to be its own helper function, surely it works differently. This is 3.11 code

static PyObject *
long_neg(PyLongObject *v)
{
    PyLongObject *z;
    if (IS_MEDIUM_VALUE(v))
        return _PyLong_FromSTwoDigits(-medium_value(v));
    z = (PyLongObject *)_PyLong_Copy(v);
    if (z != NULL)
        Py_SET_SIZE(z, -(Py_SIZE(v)));
    return (PyObject *)z;
}

As you can see, they used to the negation (of an object, they are shortcutting for small numbers) with Py_SIZE negation, playing a dirty trick anymore. If you check out the same in 3.12, you can get a good idea of how it's now.

static PyObject *
long_neg(PyLongObject *v)
{
    PyLongObject *z;
    if (_PyLong_IsCompact(v))
        return _PyLong_FromSTwoDigits(-medium_value(v));
    z = (PyLongObject *)_PyLong_Copy(v);
    if (z != NULL)
        _PyLong_FlipSign(z);
    return (PyObject *)z;
}

So, I guess, you would have to add a _NuitkaLong_FlipSign with the code of 3.11 and 3.12 behind #if

from nuitka.

kayhayen avatar kayhayen commented on September 26, 2024
#if PYTHON_VERSION < 0x3c0
#define _NuitkaLong_FlipSign(x) Py_SET_SIZE(x, -(Py_SIZE(x)));
#else
#define _NuitkaLong_FlipSign _PyLong_FlipSign
#endif

This should be it. Find all the places that do this, and call the new "function" from there. If done correctly, you see no change for Python3.11, and for Python3.12 one C compile error will be gone. The proper spot could be nuitka/build/include/nuitka/helper/ints.h although maybe I forgot and there is a better one.

Then rinse and repeat. For everything done there, we have a Python longobject code that we need to make portable across versions essentially.

from nuitka.

kayhayen avatar kayhayen commented on September 26, 2024

The 0x3c0 is 3.12

from nuitka.

kayhayen avatar kayhayen commented on September 26, 2024

I did this and it's currently on factory branch.

from nuitka.

quaesitor-scientiam avatar quaesitor-scientiam commented on September 26, 2024

Bummer, sorry didn't know you were going to move this fast on this issue. Thanks anyway

from nuitka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.