Giter VIP home page Giter VIP logo

Comments (3)

micahcochran avatar micahcochran commented on May 22, 2024

Geod and Proj both have __new__ methods. Looking at the python docs, it looks like self should be changed to cls for the __new__ method. This is something I noted while looking at this and does nothing to answer your question, sebhahn.

from pyproj.

micahcochran avatar micahcochran commented on May 22, 2024

I tried __init__ vs __new__ with the Geod class this a little when I was fixing issues #64 (PR #65). IMHO Cython's documentation isn't clear enough about what is happening during object creation regarding __new__ and __cinit__. So, some of this is my conjecture about how the functions __init__, __cinit__, and __new__.

For Proj, the __new__() is called first, which subsequently calls _proj.Proj.__new__(), which I assume is an alias for the __cinit__(). If you were to rename the Proj class function to __init__() it would happen after the function has been initialized. What is in __new__() is python code that parses parameters or makes ellipse calculations and passes it up to something that the __cinit__ which interfaces with the rest of the C code (proj.4 library).

That could probably be moved directly into the Cython __cinit__ functions, but then the code would also have to be compiled along with the rest of it.

The __new__ function has a cls parameter (which is currently confusingly called self as mentioned previously), which should not be stored to because the memory has not yet be allocated, which was what was happening in issue #64 .

TLDR The best answer is that __new__ was a design decision to add functionality in python code, then calls the corresponding Cython code to initialize the C library facing parts. __init__ would happen after __cinit__ meaning that the code in __new__ would not be able to feed into __cinit__.

from pyproj.

snowman2 avatar snowman2 commented on May 22, 2024

This has changed in the most recent version 2.1.0.

from pyproj.

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.