Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9614

Re: Is there a way to customise math.sqrt(x) for some x?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder5.news.weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.011
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'wrote:': 0.15; 'grep': 0.16; 'operators,': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'missed': 0.24; 'object': 0.30; 'from:addr:web.de': 0.30; 'subject:?': 0.31; 'seem': 0.31; 'usual': 0.32; "skip:' 10": 0.32; 'to:addr:python-list': 0.34; 'header:X-Complaints-To:1': 0.34; 'there': 0.34; 'addition,': 0.36; 'but': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'steven': 0.38; 'think': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'methods': 0.40; 'something.': 0.91; 'subject:there': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Peter Otten <__peter__@web.de>
Subject Re: Is there a way to customise math.sqrt(x) for some x?
Date Sat, 16 Jul 2011 11:37:18 +0200
Organization None
References <4e214d5a$0$29975$c3e8da3$5496439d@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
X-Gmane-NNTP-Posting-Host p50849f26.dip.t-dialin.net
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1107.1310809049.1164.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1310809049 news.xs4all.nl 23907 [2001:888:2000:d::a6]:47097
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:9614

Show key headers only | View raw


Steven D'Aprano wrote:

> I have a custom object that customises the usual maths functions and
> operators, such as addition, multiplication, math.ceil etc.
> 
> Is there a way to also customise math.sqrt? I don't think there is, but I
> may have missed something.

There seem to be only three methods that can be customized:

$ grep 'LookupSpecial' mathmodule.c
    method = _PyObject_LookupSpecial(number, "__ceil__", &ceil_str);
    method = _PyObject_LookupSpecial(number, "__floor__", &floor_str);
    trunc = _PyObject_LookupSpecial(number, "__trunc__", &trunc_str);

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Is there a way to customise math.sqrt(x) for some x? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-07-16 18:35 +1000
  Re: Is there a way to customise math.sqrt(x) for some x? Chris Angelico <rosuav@gmail.com> - 2011-07-16 19:14 +1000
    Re: Is there a way to customise math.sqrt(x) for some x? Nobody <nobody@nowhere.com> - 2011-07-16 14:42 +0100
    Re: Is there a way to customise math.sqrt(x) for some x? John Nagle <nagle@animats.com> - 2011-07-23 08:31 -0700
  Re: Is there a way to customise math.sqrt(x) for some x? Peter Otten <__peter__@web.de> - 2011-07-16 11:37 +0200
  Re: Is there a way to customise math.sqrt(x) for some x? Gary Herron <gherron@islandtraining.com> - 2011-07-16 08:56 -0700
  Re: Is there a way to customise math.sqrt(x) for some x? rantingrick <rantingrick@gmail.com> - 2011-07-23 14:09 -0700

csiph-web