{"action":"created","issue":{"url":"https://api.github.com/repos/aleaxit/gmpy/issues/122","repository_url":"https://api.github.com/repos/aleaxit/gmpy","labels_url":"https://api.github.com/repos/aleaxit/gmpy/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/aleaxit/gmpy/issues/122/comments","events_url":"https://api.github.com/repos/aleaxit/gmpy/issues/122/events","html_url":"https://github.com/aleaxit/gmpy/issues/122","id":183913675,"number":122,"title":"Add support for __new__","user":{"login":"jdemeyer","id":3625785,"avatar_url":"https://avatars.githubusercontent.com/u/3625785?v=3","gravatar_id":"","url":"https://api.github.com/users/jdemeyer","html_url":"https://github.com/jdemeyer","followers_url":"https://api.github.com/users/jdemeyer/followers","following_url":"https://api.github.com/users/jdemeyer/following{/other_user}","gists_url":"https://api.github.com/users/jdemeyer/gists{/gist_id}","starred_url":"https://api.github.com/users/jdemeyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdemeyer/subscriptions","organizations_url":"https://api.github.com/users/jdemeyer/orgs","repos_url":"https://api.github.com/users/jdemeyer/repos","events_url":"https://api.github.com/users/jdemeyer/events{/privacy}","received_events_url":"https://api.github.com/users/jdemeyer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-19T09:42:45Z","updated_at":"2016-11-02T05:41:20Z","closed_at":null,"body":"Is there any specific reason why `__new__` is not defined for the `gmpy2` types? You already have the `Pympz_new` function, which essentially implements `tp_new`.\n\n```\nIn [1]: from gmpy2 import mpz as make_mpz\n\nIn [2]: mpz = type(make_mpz())\n\nIn [3]: mpz.__new__(mpz)\n---------------------------------------------------------------------------\nTypeError                                 Traceback (most recent call last)\n<ipython-input-3-1628ff8a09e4> in <module>()\n----> 1 t.__new__(t)\n\nTypeError: object.__new__(mpz) is not safe, use mpz.__new__()\n```\n\nBeing able to create `mpz` objects using `__new__` is crucial to allow other packages to interface efficiently with `gmpy2`.\n\nIt would also make sense to implement `__init__` which could replace the `mpz()` factory function. Personally, I care much less about this part.\n"},"comment":{"url":"https://api.github.com/repos/aleaxit/gmpy/issues/comments/257777628","html_url":"https://github.com/aleaxit/gmpy/issues/122#issuecomment-257777628","issue_url":"https://api.github.com/repos/aleaxit/gmpy/issues/122","id":257777628,"user":{"login":"casevh","id":1645935,"avatar_url":"https://avatars.githubusercontent.com/u/1645935?v=3","gravatar_id":"","url":"https://api.github.com/users/casevh","html_url":"https://github.com/casevh","followers_url":"https://api.github.com/users/casevh/followers","following_url":"https://api.github.com/users/casevh/following{/other_user}","gists_url":"https://api.github.com/users/casevh/gists{/gist_id}","starred_url":"https://api.github.com/users/casevh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/casevh/subscriptions","organizations_url":"https://api.github.com/users/casevh/orgs","repos_url":"https://api.github.com/users/casevh/repos","events_url":"https://api.github.com/users/casevh/events{/privacy}","received_events_url":"https://api.github.com/users/casevh/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T05:41:20Z","updated_at":"2016-11-02T05:41:20Z","body":"I have a prototype for __new__ that ignores any arguments and just returns mpz(0). Are you planning to pass it a Python int/long or do you want to use something like mpz_import(...) to convert some sequence of bytes to an mpz_t?"}}
{"actor":{"display_login":"casevh"}}