Ticket #7976 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

Extends __classcall__ to control inheritance

Reported by: hivert Owned by: hivert
Priority: major Milestone: sage-4.3.2
Component: categories Keywords: ClassCall, inheritance
Cc: sage-combinat Work issues:
Report Upstream: N/A Reviewers: Nicolas M. Thiéry
Authors: Florent Hivert Merged in: sage-4.3.2.alpha0
Dependencies: Stopgaps:

Description (last modified by nthiery) (diff)

This patch extends ClasscallMetaclass so that one can control the call of a class trough two different static methods:

  • __classcall__ which behaves as usual and is inherited
  • __classcall_private__ which is not called by derived classes

If both exists the later is used.

By the way it does some polishing of the code.

Attachments

trac_7976-classcall_no_inherits-review-nt.patch Download (4.3 KB) - added by nthiery 3 years ago.
trac_7976-classcall_no_inherits-fh.patch Download (6.2 KB) - added by hivert 3 years ago.

Change History

comment:1 Changed 3 years ago by hivert

  • Status changed from new to needs_review

comment:2 follow-up: ↓ 3 Changed 3 years ago by nthiery

  • Keywords ClassCall, added; ClassCall removed
  • Reviewers set to Nicolas M. Thiéry
  • Status changed from needs_review to needs_work

Thanks Florent, and thanks for using this occasion to cleanup my code!

Can you fix the copyright dates? Mine should be 2009, and yours 2010

I like the idea of using Python's standard convention for private attributes; on the other hand, I am a bit worried about emulating Python's mechanism. In particular, we could eventually get in trouble with the class name hacking we do for pickling:

   sage: Sets.ParentMethods.__name__
   'Sets.ParentMethods'

I haven't found a way to *use* Python mechanism. So instead, what about using classcall_private, and doing the test with 'classcall_private' in cls.dict?

(I also prefer private to no_inherit).

Cheers,

comment:3 in reply to: ↑ 2 Changed 3 years ago by hivert

  • Status changed from needs_work to needs_review

Replying to nthiery:

Thanks Florent, and thanks for using this occasion to cleanup my code!

Can you fix the copyright dates? Mine should be 2009, and yours 2010

[...] So instead, what about using classcall_private, and doing the test with 'classcall_private' in cls.dict?

(I also prefer private to no_inherit).

I just uploaded a new patch which addresses all these remarks... Please re-review.

Changed 3 years ago by nthiery

comment:4 follow-up: ↓ 5 Changed 3 years ago by nthiery

  • Description modified (diff)
  • Milestone set to sage-4.3.2

Please double check the quick review patch, and add '#7976:' in front of the patch description, and it's good to go!

Changed 3 years ago by hivert

comment:5 in reply to: ↑ 4 Changed 3 years ago by hivert

  • Status changed from needs_review to positive_review

Replying to nthiery:

Please double check the quick review patch, and add '#7976:' in front of the patch description, and it's good to go!

I added '#7976:' and re-uploaded the patch. Thanks for the improvement of the doc. Your review patch is ok => positive review.

comment:6 Changed 3 years ago by mvngu

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.3.2.alpha0
Note: See TracTickets for help on using tickets.