Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "new" from DCD module #337

Closed
richardjgowers opened this issue Jul 6, 2015 · 5 comments
Closed

Remove "new" from DCD module #337

richardjgowers opened this issue Jul 6, 2015 · 5 comments

Comments

@richardjgowers
Copy link
Member

The DCD coordinate module uses the new module which is deprecated since 2.6.

https://docs.python.org/2/library/new.html

The imports to the DCD Reader class from the external C code need rejigging slightly to not use new.

This is blocking #260

@kain88-de
Copy link
Member

I'm not very familiar with new what rejingling would be required? To me it looks like I can make them simple class members with.

def _read_dcd_header(*args):
    return _dcdmodule.__read_dcd_header(*args)

Or does new something else then just adding a function to the class?

@orbeckst
Copy link
Member

orbeckst commented Aug 4, 2015

@kain88-de , do you want to give it a try? Once the unit tests pass and new is gone you're done ;-).

@richardjgowers
Copy link
Member Author

Sorry, I used a word that isn't a word, to rejig is to rearrange.

Basically the usage of module "new" needs removing, but no functionality
needs changing

On 11:42PM, Tue, 4 Aug 2015 Oliver Beckstein [email protected]
wrote:

@kain88-de https://github.com/kain88-de , do you want to give it a try?
Once the unit tests pass and new is gone you're done ;-).


Reply to this email directly or view it on GitHub
#337 (comment)
.

@kain88-de
Copy link
Member

Ok my naive approach doesn't work. This is because you found a way to define a python class in pure python AND C. Which is either very much discouraged or not allowed anymore, I could find any information how to do this without new.

Most of the methods in dcd.c assume that they are already an instance method. Which means I can't call them as normal functions. This would mean all of these function need to be refactored to be called as single functions. Then my approach will work. I don't have much experience writing raw cpython. For me a rewrite in cython is better but that would take a while.

@richardjgowers
Copy link
Member Author

I think new was made obsolete in favour of types, maybe if you used types.MethodType? Something like DCDReader.method = types.MethodType(_dcd.function)

https://docs.python.org/2/library/types.html#types.MethodType

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants